0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

robloxでassistant その169

Posted at

概要

robloxでassistantやってみた。
roblox見つけたので、やってみた。

参考にしたページ

写真

image.png

サンプルコード

localscript


local Common = Instance.new("Tool", game.ServerStorage)
Common.Name = "Common"
local Handle = Instance.new("Part", Common)
Handle.Size = Vector3.new(4, 1, 4)
Handle.Position = Vector3.new(0, 5, 0)
local Rare = Instance.new("Tool", game.ServerStorage)
Rare.Name = "Rare"
local Handle = Instance.new("Part", Rare)
Handle.Size = Vector3.new(1, 1, 1)
Handle.Position = Vector3.new(-2, 6, 2)
local SuperRare = Instance.new("Tool", game.ServerStorage)
SuperRare.Name = "SuperRare"
local Handle = Instance.new("Part", SuperRare)
Handle.Size = Vector3.new(1, 1, 1)
Handle.Position = Vector3.new(2, 6, -2)
local UltraRare = Instance.new("Tool", game.ServerStorage)
UltraRare.Name = "UltraRare"
local Handle = Instance.new("Part", UltraRare)
Handle.Size = Vector3.new(1, 1, 1)
Handle.Position = Vector3.new(-2, 6, -2)
local GachaMachine = Instance.new("Part", workspace)
GachaMachine.Size = Vector3.new(1, 1, 1)
GachaMachine.Position = Vector3.new(2, 6, 2)


local GachaRewards = {{ 
	Name = "コモン", 
	Probability = 50, 
	ItemName = "Common" 
}, { 
		Name = "レア", 
		Probability = 30, 
		ItemName = "Rare" 
	}, { 
		Name = "スーパーレア", 
		Probability = 15, 
		ItemName = "SuperRare" 
	}, { 
		Name = "ウルトラレア", 
		Probability = 5, 
		ItemName = "UltraRare" 
	}}
local function SpinGacha()
	local randomNumber = math.random(1, 100)
	local cumulative = 0
	for _, reward in pairs(GachaRewards) do
		cumulative = cumulative + reward.Probability
		if randomNumber <= cumulative then
			return reward.Name, reward.ItemName
		end
	end
	return "はずれ", nil
end
local function GiveItemToPlayer(player, itemName)
	local item = game.ServerStorage:FindFirstChild(itemName)
	if item then
		local newItem = item:Clone()
		newItem.Parent = player.Backpack
		print(player.Name .. " に " .. itemName .. " を渡しました。")
	else
		warn("アイテムが見つかりません: " .. itemName)
	end
end
local ClickDetector = Instance.new("ClickDetector")
ClickDetector.Parent = GachaMachine
ClickDetector.MouseClick:Connect(function(player)
	local rewardName, itemName = SpinGacha()
	print(player.Name .. " がガチャで当てた: " .. rewardName)
	if itemName then
		GiveItemToPlayer(player, itemName)
	end
	game.StarterGui:SetCore("SendNotification", {
		Title = "ガチャ結果";
		Text = "あなたが当てたアイテム: " .. rewardName;
		Duration = 3;
	})
end)



以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?