p = game.Players.LocalPlayer repeat wait() until p:FindFirstChild("Backpack") function Click() wait(2) repeat wait() until p:FindFirstChild("Backpack") game.ReplicatedStorage:GetChildren() [math.random(1, #game.ReplicatedStorage:GetChildren())]:clone().Parent = p.Backpack game.ReplicatedStorage:GetChildren() [math.random(1, #game.ReplicatedStorage:GetChildren())]:clone().Parent = p.Backpack game.ReplicatedStorage:GetChildren() [math.random(1, #game.ReplicatedStorage:GetChildren())]:clone().Parent = p.Backpack end script.Parent.MouseButton1Click:connect(Click) --// Put your code in a code block. Blue button in code editor. Code in between, all that, yeah.
This is in a localscript inside of a textbutton. When the weapons are given to the player, over half of them don't work, and it only happens to players are given the weapons by this script.
p = game.Players.LocalPlayer p:WaitForChild("Backpack") -- Waiting for the backpack before we continue our script function Click() game.ReplicatedStorage:GetChildren() [math.random(1, #game.ReplicatedStorage:GetChildren())]:clone().Parent = p.Backpack game.ReplicatedStorage:GetChildren() [math.random(1, #game.ReplicatedStorage:GetChildren())]:clone().Parent = p.Backpack game.ReplicatedStorage:GetChildren() [math.random(1, #game.ReplicatedStorage:GetChildren())]:clone().Parent = p.Backpack end script.Parent.MouseButton1Click:connect(Click)
The only thing i edited was the WaitForChild function