This ability is based on the keybind R in case you need to know that. This ability can continuously be spammed upon clicking R instead of waiting, lets say about 3 seconds, before being able to be used again. Is there a way I can add a cooldown? my code:
local tweenService = game:GetService("TweenService")
game.ReplicatedStorage.AirMagic.WindPushRE.OnServerEvent:Connect(function(player)
local character = player.Character
local properties = {
Size = Vector3.new(60 ,60, 60)
}
local newForceField = game.ServerScriptService["Wind Magic"].WindPush.WPush:Clone()
newForceField.Parent = game.Workspace
newForceField.CFrame = character.HumanoidRootPart.CFrame
local info = TweenInfo.new(0.9, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local defaultWalkSpeed = character.Humanoid.WalkSpeed
local defaultJumpPower = character.Humanoid.JumpPower
character.Humanoid.WalkSpeed = 0
character.Humanoid.JumpPower = 0
character.Humanoid.MaxHealth = 100
character.Humanoid.Health = 100
local outTween = tweenService:Create(newForceField, info, properties)
outTween:Play()
wait(1)
local properties2 = {
Transparency = 0.75;
}
wait(1)
local properties2 = {
Transparency = 0.8;
}
wait(1)
local properties2 = {
Transparency = 0.9;
}
local info2 = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
local fadeTween = tweenService:Create(newForceField, info2, properties2)
fadeTween:Play()
wait(3)
character.Humanoid.WalkSpeed = 16
character.Humanoid.JumpPower = 50
character.Humanoid.MaxHealth = 100
character.Humanoid.Health = 100
newForceField:Destroy()
end)

2 comments
thank you! I got confused since I managed to make a cooldown system without using Debounce and when I tried to add it to the current code it did not work but it does work on other code. I might have set it up wrong there. at least I can do it the proper way now too.
No problem, always happy to help