So I’m currently working on an Tool Ability System and I have a Script that teleports me but I don’t know the CoolDown function for it the CoolDown should be 10 seconds pls
local player:Player = game:GetService("Players").LocalPlayer
local character:Model = player.Character or player.CharacterAdded:Wait()
local rootPart:Part = character:WaitForChild("HumanoidRootPart")
local tool:Tool = script.Parent
local function onToolActivated()
rootPart.CFrame += rootPart.CFrame.LookVector * 5
end
tool.Activated:Connect(onToolActivated)
You add a wait time or debounce since you just want it
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local rootPart = character:WaitForChild("HumanoidRootPart")
local tool = script.Parent
local cooldownTime = 10 -- Change this value to adjust the cooldown in seconds
local debounce = false
local function onToolActivated()
if not debounce then
debounce = true
rootPart.CFrame += rootPart.CFrame.LookVector * 5
task.wait(cooldownTime)
debounce = false
end
end
tool.Activated:Connect(onToolActivated)