#While Loop stops after task.wait()

1 messages · Page 1 of 1 (latest)

cobalt vault
#

This is my module script called from the server. For some reason at init() the while loop stops at task.wait(). Why is that?

function Booster:init()
    self.loopTask = task.spawn(function()
        while self.model do
            warn("Loop started")
            task.wait()
            warn(os.time() > (self.createdTime+self.boostDuration))

            --self:setAttributes()
            if os.time() > (self.createdTime+self.boostDuration) then
                self:destroy()
                break
            end
        end
    end)    
end


and no it doesn't break because the argument after task.wait() doesn't happen either

cobalt vault
#

thanks for helping i figured its because the server script which called the module gets destroyed too early