Hi whats up, ty for clicking on this post.
It would be cool if you can help me adding A Cooldown to my script
and how to change the players speed. Ty For Helping!
1 Like
Could you tell what are you trying to achieve more detail?
1 Like
setting the player speed to 0 and adding a cooldown for the animation
To add a cooldown you need to add a debounce.
Where it says id= put the id of your animation. Then where it says wait(5) --the db time, replace the 5 for how long you want the cooldown to be.
1 Like
Try this
local db = false
local cooldownTimer = 3 -- change this on how many seconds to wait for the cooldown
script.Parent.Equipped:Connect(function(Mouse)
Mouse.Button1Down:Connect(function()
if db == false then
db = true
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0
animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
animation:Play
wait(cooldownTimer)
db = false
end
end)
end)
script.Parent.Unequipped:Connect(function()
db = false
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0
animation:Stop()
end)
2 Likes
add a db to it (OnlyTwentyCharacters )
you cant stop the animation since its inside with a differenct function
well than making instead a variable again for the animation with on a different function
just better load once
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local AnimationTrack = Humanoid:LoadAnimation(script.Parent.Animation)
local OriginalWalkSpeed = Humanoid.WalkSpeed
local Debounce = false
script.Parent.Equipped:Connect(function(Mouse)
Mouse.Button1Down:Connect(function()
if Debounce == false then
print("Applied...")
AnimationTrack:Play()
local AmountWalkSpeed = 10 -- Amount Of WalkSpeed Will Be Added
Debounce = true
Character.Humanoid.WalkSpeed += AmountWalkSpeed
wait(3) -- Duration of the walkspeed
AnimationTrack:Stop()
Character.Humanoid.WalkSpeed -= AmountWalkSpeed
wait(5) -- CoolDown (8 seconds total)
Debounce = false
else
print("Cooldown...")
end
end)
end)
script.Parent.Unequipped:Connect(function()
AnimationTrack:Stop()
Character.Humanoid.WalkSpeed = OriginalWalkSpeed
end)
2 Likes
thats also pretty good ty ty
gonna make you the solution because this is actually the best one yet