|
| 12 Feb 2016 10:29 PM |
For some reasno, the loop doesn't seem to be breaking... HELP!!!!!!
while true do wait(3) contestants = {} while #contestants < 3 do status.Value = "Waiting For Players" for _, player in pairs(game.Players:GetPlayers()) do if player and player.Character then local humanoid = player.Character:WaitForChild("Humanoid") if humanoid and humanoid.Health > 0 then table.insert(contestants, player) end end if #contestants >= 3 then break else end end end end |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 12 Feb 2016 10:51 PM |
The loop breaks the loop above it; in this case it's the for loop not the while loop do this instead: local bool = false while true do wait(3) contestants = {} while #contestants < 3 do status.Value = "Waiting For Players" for _, player in pairs(game.Players:GetPlayers()) do if player and player.Character then local humanoid = player.Character:WaitForChild("Humanoid") if humanoid and humanoid.Health > 0 then table.insert(contestants, player) end end if #contestants >= 3 then bool = true break else end end end if bool == true then bool = false break end end
|
|
|
| Report Abuse |
|
|
|
| 13 Feb 2016 08:02 AM |
| now the round starts even if there is only one player in the game... HELP @ADVANCED! |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 13 Feb 2016 08:42 AM |
while true do wait(3) contestants = {} local equalsThree = true while #contestants < 3 do status.Value = "Waiting For Players" for _, player in pairs(game.Players:GetPlayers()) do if player and player.Character then local humanoid = player.Character:WaitForChild("Humanoid") if humanoid and humanoid.Health > 0 then table.insert(contestants, player) end end if #contestants >= 3 then equalsThree = true else end end end if equalsThree == true then break end end |
|
|
| Report Abuse |
|
|
|
| 13 Feb 2016 09:15 AM |
pike this doesn't seem to be working...
while true do status.Value = "Waiting For Players" wait(3) contestants = {} local equalsThree = true while #contestants < 3 do status.Value = "Waiting For Players" for _, player in pairs(game.Players:GetPlayers()) do if player and player.Character then local humanoid = player.Character:WaitForChild("Humanoid") if humanoid and humanoid.Health > 0 then table.insert(contestants, player) end end if #contestants >= 3 then equalsThree = true else end end end if equalsThree == true then break end end
|
|
|
| Report Abuse |
|
|
|
| 13 Feb 2016 09:16 AM |
Yeah I sent you an errored script!
while true do status.Value = "Waiting For Players" wait(3) contestants = {} local equalsThree = false -- my mistake :( while #contestants < 3 do status.Value = "Waiting For Players" for _, player in pairs(game.Players:GetPlayers()) do if player and player.Character then local humanoid = player.Character:WaitForChild("Humanoid") if humanoid and humanoid.Health > 0 then table.insert(contestants, player) end end if #contestants >= 3 then equalsThree = true else end end end if equalsThree == true then break end end
|
|
|
| Report Abuse |
|
|
|
| 13 Feb 2016 09:23 AM |
| pike. I don't know what's going on. For some reason it just skips this part even if there is less than 3 people in the game. |
|
|
| Report Abuse |
|
|
|
| 13 Feb 2016 09:27 AM |
In that case, I'm adding a few print statements so we can see what the script sees:
while true do status.Value = "Waiting For Players" wait(3) local contestants = {} local equalsThree = false -- my mistake :( while #contestants < 3 do status.Value = "Waiting For Players" for _, player in pairs(game.Players:GetPlayers()) do if player and player.Character then local humanoid = player.Character:WaitForChild("Humanoid") if humanoid and humanoid.Health > 0 then table.insert(contestants, player) end end if #contestants >= 3 then print(#contestants.." is three!") equalsThree = true else end end end if equalsThree == true then break end end |
|
|
| Report Abuse |
|
|
|
| 13 Feb 2016 09:33 AM |
Okay, I found the problem. Your while loop keeps adding the same players because the contestants table is never re-declared inside of the second while loop. This crashed my Studio so I'm not entirely sure if it works (it won't crash yours), but it should work:
while true do status.Value = "Waiting For Players" wait(3) local contestants = {} local equalsThree = false -- my mistake :( while #contestants < 3 do contestants = {} wait(0.1) status.Value = "Waiting For Players" for _, player in pairs(game.Players:GetPlayers()) do if player and player.Character then local humanoid = player.Character:WaitForChild("Humanoid") if humanoid and humanoid.Health > 0 then table.insert(contestants, player) end end if #contestants >= 3 then print(#contestants.." is three!") equalsThree = true else end end end if equalsThree == true then break end end |
|
|
| Report Abuse |
|
|
|
| 13 Feb 2016 09:39 AM |
| ik, i just figured that out a couple of minutes ago by myself. For some reason everything works fine in start server mode, but when i play the game online, it just skips this part of the script and starts the game even if there is only one person playing. |
|
|
| Report Abuse |
|
|
| |
|
|
| 13 Feb 2016 10:38 AM |
@advanced
I was wrong about it working.
For some reason when i do "start server" in studio and when I upload my game to roblox, this part of the script seems to be skipped and the game starts even if there is less than 3 players in the game. help?! |
|
|
| Report Abuse |
|
|
| |
|