EDIT: Resolved by legokendall
For some reason, the "for i=1,#cooldown do" part doesn't work. However, everything else works. Any idea why? Also note that I've tried printing out plr, stat, and cooldown in function Cooldown(), and they all gave me the correct results.
wait()
function Cooldown(plr)
local stat = game.ServerStorage.PlayerStats2:FindFirstChild(plr.Name):WaitForChild("SummonCooldown")
local cooldown = stat.Value
for i=1,#cooldown do
wait(1)
stat.Value = stat.Value - 1
end end
function game.ReplicatedStorage.CheckSummonCooldown.OnServerInvoke(plr,cooldown)
local stat = game.ServerStorage.PlayerStats2:FindFirstChild(plr.Name):WaitForChild("SummonCooldown")
if stat.Value == 0 then
stat.Value = cooldown
coro = coroutine.create(Cooldown)
coroutine.resume(coro,plr)
return 0
else
return stat.Value
end end
