I have created a game where it chooses a seeker and the rest of the people have to hide in a map(s). I have it basically scripted, except how the game loop is runned by/off. I HAD it runned like this...
game.Players.PlayerAdded:connect(function() -- code to run the game (which includes teleporting, map choosing, round time, round end gui, more guis, and the loop end -- end)
The problem with this is that the loop runs everytime someone joins the game. So I had this loop run off another piece of code that allowed it so that the game needed 2 players to start. But even still that didn't change anything. The loop can still run multiple times at the same time, messing the game up:( I dont know how to run the loop another way? Plz help?
One thing you could do is use a while loop and check the number of players:
local lobbytime = yourintermissionlength local play = false while true do if game.Players.NumPlayers >= 2 then if play == false then wait(lobbytime) play = true else --your code play = false end end end
The way I would prefer would be something like this
repeat wait() until game.Players.NumPlayers >= 2 function game() game.Players.PlayerRemoving:connect(function(plr) if plr == your_it_or_something or game.Players.NumPlayers < 2 then return nil --(or something else you want to put to stop the function) end end) --game code end game()
your_it_or_something
is what I put for a conditional statement checking if the player was the seeker. Depending on how you track the seeker, you can change this statement. If you can tell me how you keep track of who is "it" then I can help you replace that bit. Here are some basic things:
-if the seeker's NAME is stored in a local variable, change the line to
if plr.Name == seekervariable then --seekervariable would be your local seeker tracking variable
-if the seeker's PLAYER is stored in a local variable, change the line to
if plr == seekervariable then --seekervariable would be your local seeker tracking variable
Once again, it would help if I could know how you store it.