Basically I have this tournament game where it goes through each match playing 2 individuals each time. From there, I use a repeat loop until either the match is over, or there is no match meaning on the tournament board, the player did not have an opponent to play.

--Current Script--
if playing.Value == true then
      repeat wait(1) until playing.Value == false
elseif notplaying.Value == true then
      repeat wait(1) until notplaying.Value == false
end

--New Script--
hold = coroutine.create(function()
      while playing.Value == false do
            coroutine.yield()
      end
      while notplaying.Value == false do
            coroutine.yield()
      end
end

coroutine.resume(hold) 

Will this function work the same as my repeat loop? I was thinking that doing this would save a lot of server lag.

Thanks,

LukeGabriel

P.S./Edit: Is there a better way to run the repeat loop without having it take so much of the server activity?

2 comments

1

Honestly a repeated loop won't cause any noticeable lag. If Roblox couldn't handle that - then you would be very limited with what you could do in the Studio.

0

I just wanted to know if there was a better way to run it since it runs a fair amount of script activity