So ive made a hammer that does a lot of damage to a humanoid, and then i made a script that slows down the player when you equip the hammer.
local Tool = script.Parent local plr = game:GetService('Players').LocalPlayer local Enabled = false Tool.Activated:Connect(function() if not Enabled then Enabled = true plr.Character.Humanoid.WalkSpeed = 3 else Enabled = false plr.Character.Humanoid.WalkSpeed = 16 end end)
But then whenever i clicked the walkspeed resets to normal! I thought it might be the damage script so i put that in server storage to see if it worked after that, and even without the damage scripts the walkspeed resets to normal when you click the mouse! It also turns it back to 3 when you click again. Could anyone point out a problem as this is completely beyond me lol.
That's because the script just toggles the walkspeed when walking.
local Tool = script.Parent local plr = game:GetService('Players').LocalPlayer local deb = false local cooldown = 0.5 -- how long you walk slower in seconds you can set it to anything you want for example 1 to 1 second Tool.Activated:Connect(function() -- fires on activated if deb then return end -- stop when debounce is active deb = true plr.Character.Humanoid.WalkSpeed = 3 wait(cooldown) plr.Character.Humanoid.WalkSpeed = 16 deb = false end)