01 | p = game.Players.LocalPlayer |
02 | repeat wait() until p:FindFirstChild( "Backpack" ) |
03 | function Click() |
04 | wait( 2 ) |
05 | repeat wait() until p:FindFirstChild( "Backpack" ) |
06 | game.ReplicatedStorage:GetChildren() [ math.random( 1 , #game.ReplicatedStorage:GetChildren()) ] :clone().Parent = p.Backpack |
07 | game.ReplicatedStorage:GetChildren() [ math.random( 1 , #game.ReplicatedStorage:GetChildren()) ] :clone().Parent = p.Backpack |
08 | game.ReplicatedStorage:GetChildren() [ math.random( 1 , #game.ReplicatedStorage:GetChildren()) ] :clone().Parent = p.Backpack |
09 | end |
10 |
11 | script.Parent.MouseButton 1 Click:connect(Click) |
12 | --// 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.
1 | p = game.Players.LocalPlayer |
2 | p:WaitForChild( "Backpack" ) -- Waiting for the backpack before we continue our script |
3 | function Click() |
4 | game.ReplicatedStorage:GetChildren() [ math.random( 1 , #game.ReplicatedStorage:GetChildren()) ] :clone().Parent = p.Backpack |
5 | game.ReplicatedStorage:GetChildren() [ math.random( 1 , #game.ReplicatedStorage:GetChildren()) ] :clone().Parent = p.Backpack |
6 | game.ReplicatedStorage:GetChildren() [ math.random( 1 , |
7 | #game.ReplicatedStorage:GetChildren()) ] :clone().Parent = p.Backpack |
8 | end |
9 | script.Parent.MouseButton 1 Click:connect(Click) |
The only thing i edited was the WaitForChild function