generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: help!

Previous Thread :: Next Thread 
swimmaster07 is not online. swimmaster07
Joined: 08 Jun 2013
Total Posts: 1459
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
swimmaster07 is not online. swimmaster07
Joined: 08 Jun 2013
Total Posts: 1459
12 Feb 2016 10:37 PM
B
Report Abuse
swimmaster07 is not online. swimmaster07
Joined: 08 Jun 2013
Total Posts: 1459
12 Feb 2016 10:47 PM
B2
Report Abuse
AdvancedObjects is not online. AdvancedObjects
Joined: 11 Dec 2012
Total Posts: 3354
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
swimmaster07 is not online. swimmaster07
Joined: 08 Jun 2013
Total Posts: 1459
13 Feb 2016 08:02 AM
now the round starts even if there is only one player in the game... HELP @ADVANCED!
Report Abuse
swimmaster07 is not online. swimmaster07
Joined: 08 Jun 2013
Total Posts: 1459
13 Feb 2016 08:27 AM
advanced help please.
Report Abuse
swimmaster07 is not online. swimmaster07
Joined: 08 Jun 2013
Total Posts: 1459
13 Feb 2016 08:39 AM
b
Report Abuse
wonderful72pike is not online. wonderful72pike
Joined: 13 Jul 2010
Total Posts: 7009
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
swimmaster07 is not online. swimmaster07
Joined: 08 Jun 2013
Total Posts: 1459
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
wonderful72pike is not online. wonderful72pike
Joined: 13 Jul 2010
Total Posts: 7009
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
swimmaster07 is not online. swimmaster07
Joined: 08 Jun 2013
Total Posts: 1459
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
wonderful72pike is not online. wonderful72pike
Joined: 13 Jul 2010
Total Posts: 7009
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
wonderful72pike is not online. wonderful72pike
Joined: 13 Jul 2010
Total Posts: 7009
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
swimmaster07 is not online. swimmaster07
Joined: 08 Jun 2013
Total Posts: 1459
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
swimmaster07 is not online. swimmaster07
Joined: 08 Jun 2013
Total Posts: 1459
13 Feb 2016 09:45 AM
Halp
Report Abuse
swimmaster07 is not online. swimmaster07
Joined: 08 Jun 2013
Total Posts: 1459
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
swimmaster07 is not online. swimmaster07
Joined: 08 Jun 2013
Total Posts: 1459
13 Feb 2016 10:58 AM
NVM I GOT IT WORK!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image