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)
I think your looking for Debounce, Debounce Is the cooldown
Example Script:
local Part = script.Parent local Debounce = false Part.Touched:Connect(function(hit) if not Debounce then local Humanoid = hit.Parent:WaitForChild("Humanoid") if Humanoid then Debounce = true print("Hey! Stop stepping on me! >:(") wait(1) Debounce = false end end end)