is there way that i can add Cooldown
in RunService
if it’s is so please help me how i can do it
i just want to know how i can add cooldown with runservice
Yea, u can and here is the way:
local RunService = game:GetService("RunService")
local cooldown = 5 -- Cooldown
local last = 0
RunService.Heartbeat:Connect(function()
local current = tick()
if current - last >= cooldown then
print("do smth")
last = current
end
end)
1 Like
Adding a cooldown to something bound to RunService has the same effect as an infinite while loop that yields
task.spawn(function()
while true do
--do stuff
task.wait(cooldown)
end
end)
it doesn’t rlly yield a thread
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.