I’m trying to make it so when the player press the key once it puts it on cooldown for 5 seconds but nothing is working
Teleportation.OnServerEvent:Connect(function(plr,mousepos)
local db = false
local plr = plr
local mouse = plr:GetMouse()
local char = plr.Character
local HRP = char.HumanoidRootPart
if not db then
db = true
HRP.Position = mousepos
task.wait(5)
db = false
end
end)
I’ve tried doing it in a local script but nothing is working.
move db out of the function, you’re overwriting it everytime it runs
local db = false
Teleportation.OnServerEvent:Connect(function(plr,mousepos)
local plr = plr
local mouse = plr:GetMouse()
local char = plr.Character
local HRP = char.HumanoidRootPart
if not db then
db = true
HRP.Position = mousepos
task.wait(5)
db = false
end
end)