Your script currently check if it is equipped only one time.
You can use loops such as while or repeat in order to make your wish true
local tool = script.Parent
local cooldown = 0
while wait(1) do
if tool.Equipped == false then
cooldown = cooldown + 1
if cooldown >= 10 then
tool:Destroy()
end
else cooldown = 0
end
end
Made it as simple as it possible, and here how it works:
This script checks every second if tool is equipped. If not, it will increase cooldown until it will reach number 10 and then, it will destroy tool.
local tool = script.Parent
local cooldown = 0
function onEquipped()
cooldown = 0
end
tool.Equipped:connect(onEquipped()
while wait(1) do
if not tool.Equipped then
if cooldown >= 10 and not tool.Parent:FindFirstChild("Humanoid") then
tool:Destroy()
elseif not tool.Parent:FindFirstChild("Humanoid") then
cooldown = cooldown + 1
end
end
end
This one might help, I really dunno what is the problem
while true do
wait(5)
if script.Parent.Parent:FindFirstChild("Humanoid") or script.Parent.Parent.Name == "Backpack" then
--Do nothing
else
wait(1)
script.Parent:Destroy()
break
end
end