nothing is working, only prints 'whats wrong?' in the output...
01 | running = false |
02 | enough = game.Players.NumPlayers |
03 |
04 | if (running = = false and enough > = 1 ) then |
05 | running = true |
06 | while true do |
07 | m = Instance.new( "Message" , Workspace) |
08 | m.Text = "Now starting a new game!" |
09 | wait( 1 ) |
10 | m:Destroy() |
11 | for i, v in pairs (game.Players:GetChildren()) do |
12 | if v.Character.BoolValue.Value = = true then |
13 | print (v.Name .. " has been found" ) |
14 | v.Character.Torso.CFrame = Vector 3. new( 10 , 10 , 10 ) |
15 | end |
"Most likely the script loads before game.Players.NumPlayers changes to 1 because the server is started and scripts are run before the client is connected to it." - 1Waffle1
1 | game.Players.PlayerAdded:connect( function (plr) |
2 | if (running = = false and enough > = game.Players.NumPlayers) then |
3 | --etc. |
This will let it check every time a player joins to see if there are enough players.
Most likely the script loads before game.Players.NumPlayers changes to 1 because the server is started and scripts are run before the client is connected to it.
Yeah, the script loads before NumPlayers is updated with 1 as it's value. Try asking if enough is greater than (not greater than or equal to) 0. However, you should put that into a looped wait with that set as the condition if you want it to wait until there are enough players.