I have created a script which assigns the boolean 'playing' to each player when the enter the server. When they click the GUI button 'start' this changes to true, however this is not the problem.
My main server script for the execution of the game calls an error because (as far as I am aware) the script is performed on the player before my other script assigns the 'playing' bool to them when they join. I have a bad workaround this by adding a temporary 'wait' for 10 seconds for them to load in fully and be assigned the 'playing' bool but this still crashes if another player joins after that first 10 seconds as it constantly loops through checking if the players have the variable.
playable = false
--wait(10) --So the game has time to assign 'playing' to players
while not playable do
--This creates a new array of players who have actually clicked "start", we don't want the hunter to be in the main menu.
players = game.Players:GetChildren() -- String array where we store all the players
playingPlayers = {}
for i = 1, # players do
local playing = players[i].playing.Value
if playing == true then
table.insert(playingPlayers, players[i])
end
end
lobbyAmount = tablelength(playingPlayers)
wait()
if lobbyAmount < 2 then
print("Not enough players")
else
playable = true
end
end
This is the main server script ^
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(modelPlayer)
local playing = Instance.new("BoolValue")
playing.Name = "playing"
playing.Parent = player
playing.Value = false
end)
end)
This is the other script that assigns the bool to the player. ^
It crashes on 'local playing = players[i].playing.Value as when the player first joins the other script doesn't have time to assign that variable to them (I think that's what is happening anyway). I'm pretty stuck on how to solve this, any help would be appreciated thanks!

7 comments
I’m sure the while loop won’t run if “playable” is true. Therefore those “if” recursers won’t run.
The while loop definitely runs, as playable is set to false at the start and the while loop runs for as long as playable is set to false. I get an error at line 08 so that's the problem, maybe I didn't explain it well enough in the post.
Don't use instances to tag players, use collection service dang it...
I'm pretty new to lua, so sorry if I'm doing something that's frowned upon, I've never heard of collection service before, how would it interact differently ?
I write round based scripts all the time. In part of it, I wait for there to be enough players in order to do something. I'll write that piece for you.
Thanks, appreciate it
< 2 which means 1 or less. Line 15. I looked at it the moment I opened this thread.