So I have a button that gives the user a gun than destroys the one they have in there inventory but if you click the button again within a few seconds the gun will be destroyed and nothing will be in its place. I tried adding a wait but that did nothing, here is the code
local button = script.Parent local plr = game:GetService('Players').LocalPlayer local tool = game.ReplicatedStorage.ACS_Engine.HOOD["Micro UZI"] button.Activated:Connect(function() script.Parent.Parent.Visible = false plr.Backpack:FindFirstChildWhichIsA('Tool'):Destroy() local clone = tool clone.Parent = plr.Backpack wait(0.5) script.Parent.Parent.Parent.ClassH.Visible = true wait(3) script.Parent.Parent.Parent.ClassH.Visible = false end)
Thanks!
Try This:
local button = script.Parent local plr = game:GetService('Players').LocalPlayer local tool = game.ReplicatedStorage.ACS_Engine.HOOD["Micro UZI"]:Clone() button.Activated:Connect(function() script.Parent.Parent.Visible = false plr.Backpack:FindFirstChildWhichIsA('Tool'):Destroy() tool.Parent = plr.Backpack wait(0.5) script.Parent.Parent.Parent.ClassH.Visible = true wait(3) script.Parent.Parent.Parent.ClassH.Visible = false end)
local button = script.Parent local plr = game:GetService('Players').LocalPlayer local tool = game.ReplicatedStorage.ACS_Engine.HOOD['Micro UZI'] local cooldown = false --//r button.Activated:Connect(function() if cooldown == false then --//r cooldown = true --//r script.Parent.Parent.Visible = false plr.Backpack:FindFirstChildWhichIsA('Tool'):Destroy() local clone = tool:Clone() --// You forgot the :Clone() clone.Parent = plr.Backpack wait(0.5) script.Parent.Parent.Parent.ClassH.Visible = true wait(3) script.Parent.Parent.Parent.ClassH.Visible = false cooldown = false --//r end --//r end)
You forgot to actually clone the tool. You were just grabbing the tool from replicated storage and placing it into the players backpack without making a copy.
I also added a cooldown, if you dont want it just remove the things labeled --//r