This is a tool that pulls things towards you when you click on them. My problem is that it keeps working even after I unequip the tool. How do I fix it?
player = game.Players.LocalPlayer
mouse = player:GetMouse()
local debounce = true
script.Parent.Equipped:Connect(function()
mouse.Button1Down:connect(function()
mouse.TargetFilter = game.Workspace:FindFirstChild("7")
if debounce == true then
if mouse.Target.Anchored == false and mouse.Target.Name == "Part" then
local Sound = Instance.new("Sound", mouse.Target)
Sound.SoundId = "rbxassetid://131526385"
Sound.Volume = 1
if not Sound.IsPlaying then
Sound:Play()
end
local rp = Instance.new("RocketPropulsion", mouse.Target)
mouse.Target.Anchored = false
rp.MaxSpeed = 50
rp.Target = player.Character.Torso
rp:Fire()
local distance = (mouse.Target.Position - player.Character.Torso.Position).Magnitude
print(distance)
mouse.Target.Touched:connect(function(hit)
hit = hit.Parent:FindFirstChild("Humanoid")
if hit then
rp:Destroy()
end
Sound:Destroy()
debounce = false
wait(2)
debounce = true
end)
end
end
end)
end)
script.Parent.Unequipped:Connect(function()
--what do I do here??
end)

4 comments
That works, but I need to have a cool-down time, too.
I need to keep this part: "debounce = false wait(2) debounce = true"
The equip part shouldn't interfere with the cooldown if it already worked, though. I don't think you need to change it to what I have.
It worked. Thanks.