#help i made a tool script when press Q will CD 60sec but if rehold the tool the CD will reset ple

2 messages · Page 1 of 1 (latest)

open oak
#

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)

#

Effect:
script.Parent.OnServerEvent:Connect(function(plr)
local Effect = game.ReplicatedStorage.Asset.Effect:Clone()
Effect.Parent = workspace
Effect.CanCollide = false
Effect.Anchored = true
Effect.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-8) * CFrame.fromEulerAnglesXYZ(0,0,0)
wait(0.2)
for i = 1,18 do
wait(0.01)
Effect.Size = Effect.Size + Vector3.new(2,2,2)
Effect.Transparency = Effect.Transparency + 0.025
end
Effect:Destroy()
wait(0.2)
end)