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)
Do something like this that checks if it's equipped or not
e = false script.Parent.Equipped:Connect(function () e= true end) script.Parent.Unequipped:Connect(function() e= false end) --have the rest of the stuff here but have it check if e is true or not
For the cooldown
a = false function cool() a = true wait(cooldown time) a = false end if a == false and e == true then --all the stuff here cool()