I have been trying to script a cooldown system for roll() function for my rolling script but it seems doesn’t work.
Script:
local countdown = coroutine.create(function(player)
print("countin")
wait(1)
tempdata["cd" .. player.UserId] = 0
end)
local function cooldown(player)
if tempdata["cd" .. player.UserId] == 0 then
tempdata["cd" .. player.UserId] = 1
coroutine.resume(countdown(player))
print("in cd")
return true
else
print("sus behavior " .. player.Name)
return false
end
end
local function roll(player)
local cd = cooldown(player)
...
Error:
attempt to call a thread value