How do i make a tool switching cooldown?

sooo im trying to make a tool switching cooldown like after you equip a tool u cant unequip it for 1 second and once that second is done u can unequip it. this is all i have and it doesnt work at all

local tool = script.Parent

tool.Unequipped:Connect(function()
	tool.Enabled = false
	task.wait(1)
	tool.Enabled = true
end)

I may be of no help but here we go:

local tool: Tool = script.Parent

local backpack = tool.Parent
local otheparent -- Whenever equipped this is set

local cooldowntime = 1 -- I assume you want this number

local ison = false
local cooldown = false

local quickcool = false -- so the whole thing doesn't call itself billions of times

tool:GetPropertyChangedSignal("Parent"):Connect(function ()
	if not quickcool then
		if not cooldown then
			if tool.Parent == backpack then
				ison = false
			else
				ison = true
				otheparent = tool.Parent
			end
			cooldown = true
			wait(cooldowntime)
			cooldown = false
		else
			if ison then
				tool.Parent = otheparent
			else
				tool.Parent = backpack
			end
		end
		wait()
	end
end)

Hope this helps!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.