How Would I Improve this matchmaking system?

The Title says it all

I’m wondering if there is a better way to create a match system

This is just an example of the code, not the actual code itself, however it should still be the same thing

while true do
   for i = 60,0,-1 do -- Intermission
-- Intermission stuff
GameSetUp() -- Setup of game (Lets just say there is code here)
   for i = Seconds*60,0,-1 do -- This works but i accidentally made this look weird
-- In game time and functions
     if Condition then -- If something happens

I’m just wondering what is a better way to set this up, or is this already good enough.

Its hard to help with that little information

The structure is fine but consider making all your time checks based on time() instead of counting down with (presumably wait), this will be more consistent.

1 Like

I’m more of referring to the setup of the system, not exactly the code inside, mainly the while and for loops part btw, but is there a better way of doing that?

while true do -- Maybe This
   for i = 60,0,-1 do -- This
-- This
   end -- This
GameSetUp() -- Not this
   for i = Seconds*60,0,-1 do -- This

     if Condition then -- Not This
       break -- Maybe This
     end -- Not This
   end -- This
end -- Maybe This

How would i use time() in this case?

To start a countdown of 60 seconds record the current time. Then stop the countdown on the first cycle that the current time is greater than the recorded time plus 60 seconds.

local timerLengthSeconds = 60

local startTime = time()

--Game loop, which may be something like while task.wait(1) do, or a Stepped function

if time() > startTime + timerLengthSeconds then
    --Timer ended, take some action

--End of game loop
1 Like

Huh, That might be useful, Thanks, is there anything else I can do to improve it?

still wondering :frowning: