I'm working on a script that will handle certain stats for a game, and wrote a coroutine to handle one of those stats (they must work separately), but it is halting midway through the code. I used tags to debug the block but can't find what exactly is producing this, as I get no error messages nor does the code have any syntax errors. Any help will be appreciated.
The code stops running just before the commented line (it is not commented on the real code). All variables not defined here refer to integer numbers, all correctly defined earlier in the code.
coroutine.resume(coroutine.create(function()
while true do
local mindMax = math.ceil(50 + mag.Value/5) + 250 * lv.Value
if mind.Value < mindMax/10 then
local waitTime = 2 - (dex.Value + mag.Value)/240
if waitTime > 1 then
wait(waitTime)
else
wait(1)
end
-- mind.Value = mind.Value + mindMax/50
elseif mind.Value < mindMax then
mind.Value = mind.Value + mindMax/50
elseif mind.Value > mindMax then
mind.Value = mind.Value - (mindMax - mind.Value)
end
wait(1)
end
end))

2 comments
You're using wait() which would obviously cause the code to halt.
I know I used wait, but the coroutine stops indefinitely, not just the time I specified...