So I have this button that grabs a tool from a folder than puts it into the starter pack (there are 30 tools in folder). and it only works once, I dont know why could anyone help?(ColdFoxy07 if you answer this again big susy)

local cooldown = false --//r
local button = script.Parent
local plr = game:GetService('Players').LocalPlayer

local tool = game.ReplicatedStorage.ACS_Engine.P2000GUN.P2000

button.Activated:Connect(function()
	if cooldown == false then
		cooldown = true
		script.Parent.Parent.Visible = false
		local clone = tool
		clone.Parent = plr.Backpack
		wait(0.5)
		script.Parent.Parent.Parent.TextLabel.Visible = true
		wait(3)
		script.Parent.Parent.Parent.TextLabel.Visible = false
		cooldown = false
	end
end)

5 comments

0

ALSO THIS IS THE LAST QUESTION IM ASKING

0

the issue is that when you create the variable "tool" it only gets one tool and doesnt check for other ones if its not there.

0

the best way to do it is to just clone.

0

if I do clone the tool wont work, Im not sure why

0

Thanks for the comment, I fixed it myself by removing the tool variable and adjusting the clone variable. also thanks for pointing me twords the right direction with cloning, I probobly wouldve cloned the tool if it actually worked when cloned.