Whipitz
|
  |
| Joined: 10 Oct 2008 |
| Total Posts: 1364 |
|
|
| 05 Mar 2014 05:22 PM |
while true do script.Parent.Value = math.random(1,2)
getTeamCount = function(TeamColor) local count = 0 for _,Player in next, game:GetService("Players"):GetChildren() do count = count + (Player.TeamColor==TeamColor and 1 or 0) end end
if script.Parent.Value == 1 then wait(1) game.Lighting.Search:clone().Parent = game.Workspace game.Lighting.Map1:clone().Parent = game.Workspace if getTeamCount(BrickColor.new("Lime green"))< 2 then wait(8) game.Workspace.Map1:remove() game.Workspace.Search:remove() wait(5) end elseif script.Parent.Value == 2 then wait(1) game.Lighting.Search:clone().Parent = game.Workspace game.Lighting.Map2:clone().Parent = game.Workspace if getTeamCount(BrickColor.new("Lime green"))< 2 then wait(5) game.Workspace.Map2:remove() game.Workspace.Search:remove() wait(5) end end end
it doesn't delete that map if there are less than 2 people on "Lime green".. |
|
|
| Report Abuse |
|
|
Whipitz
|
  |
| Joined: 10 Oct 2008 |
| Total Posts: 1364 |
|
| |
|
Usering
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 10281 |
|
|
| 05 Mar 2014 05:44 PM |
Do you have any errors?
~ Usering ~ |
|
|
| Report Abuse |
|
|
Whipitz
|
  |
| Joined: 10 Oct 2008 |
| Total Posts: 1364 |
|
|
| 05 Mar 2014 05:47 PM |
| 26: attempt to compare nil with number |
|
|
| Report Abuse |
|
|
ShagFace
|
  |
| Joined: 22 Aug 2011 |
| Total Posts: 3474 |
|
|
| 05 Mar 2014 05:47 PM |
Is the model named "Map1"?
Just re-check the specific model's name, as this is a common error for most scripters |
|
|
| Report Abuse |
|
|
Whipitz
|
  |
| Joined: 10 Oct 2008 |
| Total Posts: 1364 |
|
|
| 05 Mar 2014 05:48 PM |
| Yes; it does clone the map, it just doesn't remove it.. |
|
|
| Report Abuse |
|
|
Usering
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 10281 |
|
|
| 05 Mar 2014 05:51 PM |
Because you're comparing nil with a number: "if getTeamCount(BrickColor.new("Lime green"))< 2 then"
You never returned count, so the function returns nil.
getTeamCount = function(TeamColor) count = 0 for _,Player in next, game:GetService("Players"):GetChildren() do count = count + (Player.TeamColor==TeamColor and 1 or 0) end return count end
~ Usering ~ |
|
|
| Report Abuse |
|
|
Whipitz
|
  |
| Joined: 10 Oct 2008 |
| Total Posts: 1364 |
|
|
| 05 Mar 2014 05:55 PM |
| Awesome, that worked! Thanks Usering! |
|
|
| Report Abuse |
|
|
Whipitz
|
  |
| Joined: 10 Oct 2008 |
| Total Posts: 1364 |
|
|
| 05 Mar 2014 05:56 PM |
| Also, will this keep checking the number of players on the team until it finds that there is less than 2 players on the team, or does it only check once? |
|
|
| Report Abuse |
|
|
Usering
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 10281 |
|
|
| 05 Mar 2014 05:57 PM |
It will only check once since it's in that same loop.
~ Usering ~ |
|
|
| Report Abuse |
|
|
Whipitz
|
  |
| Joined: 10 Oct 2008 |
| Total Posts: 1364 |
|
|
| 05 Mar 2014 05:59 PM |
| How can I make it so that it keeps checking? |
|
|
| Report Abuse |
|
|
Usering
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 10281 |
|
|
| 05 Mar 2014 06:03 PM |
This isn't the most efficient way of doing so, but:
Put that function into a another script and have it constantly checking for the amount of players in the team. Have a IntValue in workspace where that script puts the number of players on the team. In your while loop in your script above, have a .Changed event so when the team count changes, you can check it's value and if it is less than the amount you want, then it does it's thing.
~ Usering ~ |
|
|
| Report Abuse |
|
|
Whipitz
|
  |
| Joined: 10 Oct 2008 |
| Total Posts: 1364 |
|
|
| 05 Mar 2014 06:06 PM |
| not too experienced in scripting, not sure how to do that =l |
|
|
| Report Abuse |
|
|
Whipitz
|
  |
| Joined: 10 Oct 2008 |
| Total Posts: 1364 |
|
| |
|