this is a tool script when press Q will CD 60sec but if rehold the tool the CD will reset please help fix this bug
tool inside:
SkillScript(localscript)
SkillScript inside Keybind(localscript)
Keybind inside have a RemoteEvent name called Fire
inside the RemoteEvent script:
Effect
Main
SkillScript:
local Tool = script.Parent
Tool.Equipped:Connect(function()
script.Keybind.Disabled = false
end)
Tool.Unequipped:Connect(function()
script.Keybind.Disabled = true
end)
Keybind:
local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local Debounce = true
local Player = game.Players.LocalPlayer
local Animation = script.Parent.Animation
local cooldown = 60 -- CD时间,单位为秒
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.Q and Debounce == true then
Debounce = false
local Track1 = Player.Character.Humanoid:LoadAnimation(Animation)
Track1:Play()
script.Fire:FireServer(plr)
wait(cooldown)
Debounce = true
end
end)