Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Dash Mechanic Knows No Cooldown Help?

Asked by
Kesaci 0
4 years ago
Edited 4 years ago

Okay so heres the brief explanation I made a dashing Script right but I cant seem to get it to function the way intended to so I want to make it have a cooldown script but its not working it either Only Dashes Once then completely breaks or if I remove the cooldown it'll just dash for infinitely I dont know what the issue...

local player = game.Players.LocalPlayer
repeat wait() until player.Character.Humanoid
local humanoid = player.Character.Humanoid
local mouse = player:GetMouse()
local cooldown = false

local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=04907165430" 

mouse.KeyDown:connect(function(key)
  if cooldown == true then return end
    if string.byte(key) == 113 then
      cooldown = true 
        local playAnim = humanoid:LoadAnimation(anim)
        playAnim:Play()
        script.Sound:Play()
        player.Character.HumanoidRootPart.Velocity = player.Character.HumanoidRootPart.CFrame.lookVector * 50
        wait(0.1) 
      cooldown = true
    end
    wait(0.5)
end)

1 answer

Log in to vote
0
Answered by
0msh 333 Moderation Voter
4 years ago
Edited 4 years ago

set line 19's cooldown to false, that might be the problem

you did not set the cooldown back to false as it is needed for the script to run (get past line 11), and setting the wait(0.1) a little higher would make the cooldown a little more visible

Ad

Answer this question