Krosskode
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 11001 |
|
|
| 26 Nov 2014 12:08 PM |
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 if teamValue == 1 then player.TeamColor = BrickColor.new("Bright red") table.insert(redPlayers, player) elseif teamValue == 2 then player.TeamColor = BrickColor.new("Deep blue") table.insert(bluePlayers, player) end end end end
Why won' my script change teams? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Nov 2014 12:10 PM |
| teamValue is nil as far as I can tell |
|
|
| Report Abuse |
|
|
Krosskode
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 11001 |
|
|
| 26 Nov 2014 12:12 PM |
| Oh sorry; I have all the variables; and it inserts into the table, it just doesn't switch the teams. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Nov 2014 12:13 PM |
teamValue is in a table? Or did I misunderstand you?
If I misunderstood you, print(teamValue) and see what you get. If you get nil then you might want to show more of the script. |
|
|
| Report Abuse |
|
|
Krosskode
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 11001 |
|
|
| 26 Nov 2014 12:14 PM |
This is the full section:
redPlayers = {} bluePlayers = {} teamValue = 1 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 if teamValue == 1 then player.TeamColor = BrickColor.new("Bright red") table.insert(redPlayers, player) elseif teamValue == 2 then player.TeamColor = BrickColor.new("Deep blue") table.insert(bluePlayers, player) end end end end |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Nov 2014 12:15 PM |
Oh, alright then is it possible nobody is in the server when it runs?
Try running it when you have 3 or so test players (start->server & 3 players) |
|
|
| Report Abuse |
|
|
Krosskode
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 11001 |
|
|
| 26 Nov 2014 12:16 PM |
| Before hand I do indeed have a check if two people are in; the whole script basically works except the team switching. Sorry I wasn't clear about this. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Nov 2014 12:20 PM |
Weird, I just tested it and it worked correctly.
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Nov 2014 12:22 PM |
| It might be the way you are waiting for people to enter. |
|
|
| Report Abuse |
|
|
Krosskode
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 11001 |
|
|
| 26 Nov 2014 12:30 PM |
| Actually, the whole area isn't working now, it doesn't insert into the table or change teams. |
|
|
| Report Abuse |
|
|
Krosskode
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 11001 |
|
|
| 26 Nov 2014 12:31 PM |
This is how I wait for people:
while true do wait(intermissiontime) contestants = {} 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 end if #contestants >= 2 then break else statustag.Value = "Waiting for Players" timertag.Value = -1 end end
The game starts, but it doesn't change teams or add to tables. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Nov 2014 12:31 PM |
Well it can't be the script in this thread since that is working fine. You have other scripts that insert the team? Make sure the teams are inserted before the team change occurs. |
|
|
| Report Abuse |
|
|
Krosskode
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 11001 |
|
|
| 26 Nov 2014 12:32 PM |
| The teams are there by default because it wouldn't duplicate the teams, either. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Nov 2014 12:33 PM |
Was referring to the original script (change team one).
Is this on top of the team change? |
|
|
| Report Abuse |
|
|
Krosskode
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 11001 |
|
|
| 26 Nov 2014 12:35 PM |
| Yes, it's waiting for players before changing teams. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Nov 2014 12:36 PM |
Then why not do this?
-- player waiting part up here redPlayers = {} bluePlayers = {} teamValue = 1 for _, player in pairs(contestants) do if player.Character.Humanoid.Health > 0 then if teamValue == 1 then player.TeamColor = BrickColor.new("Bright red") table.insert(redPlayers, player) elseif teamValue == 2 then player.TeamColor = BrickColor.new("Deep blue") table.insert(bluePlayers, player) end end end |
|
|
| Report Abuse |
|
|
Krosskode
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 11001 |
|
|
| 26 Nov 2014 12:39 PM |
That still hasn't worked; it's strange.
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Nov 2014 12:40 PM |
Do you know what teamviewer/join.me is? It's working fine for me, but I want to see your screen it might be a simple mistake on your part. |
|
|
| Report Abuse |
|
|
Krosskode
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 11001 |
|
|
| 26 Nov 2014 12:43 PM |
| Do you have a Skype? I just prefer that method because that's how all of my Dev teams communicate. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Nov 2014 12:48 PM |
| Yeah, I'll message you my name |
|
|
| Report Abuse |
|
|