Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would i make a gui button give you a random gear?[Put in bakcpack and starterpack]

Here is what i got so far:

local Gear = game.Lighting.DailyGiftGear:GetChildren() 
local GearChosen = {}
local numberOfGearsWanted = 1

script.Parent.MouseButton1Click:connect(function()
	for i = 1, numberOfGearsWanted do
    	GearChosen[i] = math.random(1,#Gear)
		
	end
end)

1 answer

✓ Accepted answer
local GearHolder= game.Lighting.DailyGiftGear
local Gear= GearHolder:GetChildren()
local GearChosen = {}
local numberOfGearsWanted = 1

script.Parent.MouseButton1Click:connect(function()
    for i = 1, numberOfGearsWanted do
	table.insert(GearChosen,Gear[math.random(1,#GearHolder:GetChildren()])
        GearChosen[i] = math.random(1,#Gear)
    end
	for i,v in pairs(GearChosen) do
		c=v:Clone()
		c.Parent=game.Players.LocalPlayer.Backpack
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.