This function works until I put it in a while true do loop. It will wait infinitely if I put it inside the loop.
EDIT: I've figured out the wait does work; however, for some reason, even though it's wrapped in a coroutine, it is halting the main thread. Not sure why?
function wait(seconds)
local start = os.time()
repeat until os.time() > start + seconds
end
local function countDown()
while true do
wait(1)
if isInNumberGame == true then
timeSinceLastMessage = timeSinceLastMessage - 1
if timeSinceLastMessage == 0 then
isInNumberGame = false
local messageChannel = mem.guild:getChannel("668605956426563626")
messageChannel:send("<@"..currentmember.user.id.."> Game over! Out of time to respond (the number was "..num..")")
end
end
end
end
local countDownNumGame = coroutine.wrap(countDown)
countDownNumGame()