Ticket System Help

How would I go about creating a Ticket System besides using infinite yields?

So currently, I am working on a Capture Point System, which is going great. But the problem is how would I go about creating a Ticket System? I have already tried using while wait() do, but infinite yields never go as I plan. The idea I had for a ticket system is obviously if a team owns more captured points than the enemy team, the enemy tickets will reduce every few seconds. But the problem is when the tickets are equal to 0, the only way I can stop it is by using a return statement right now, but that would end the whole script. Any feedback?

(I was planning on experimenting with repeat until but I don’t know if that is the most viable option right now.)


Have you tried using break? It stops the most recent loop

1 Like

I have. It sorta works but I want the ability to reset and restart raids without having to shutdown or switch to another server. When the function breaks and I reset every point. Every still works beside the reduction of ticket points, which ran by a while wait() do loop.

You can try using a coroutine to run the process seperately from the main loop.

For example,

local gameisrunning = true

    while gameisrunning and wait()
        -- Whatever function or ticket logic here

The loop would end if the gameisrunning variable is set to false or if you have some sort of logic inside the loop that breaks it. Creating a coroutine won’t hang your script as well. It just creates a new thread. So you could do other things on the main thread.