iHypered
|
  |
| Joined: 09 Nov 2010 |
| Total Posts: 2751 |
|
|
| 14 Jul 2016 09:52 AM |
everything works fine, except that if game.Workspace.Mode.Value == 3 it will only bring 1 player.
for i, player in ipairs(game.Players:GetChildren()) do if player.Character then if game.Workspace.Mode.Value ~= 3 then player.TeamColor = BrickColor.new("Cyan") player.Character:BreakJoints() elseif game.Workspace.Mode.Value == 3 then game.Workspace.newround.Value = 15 local red = Instance.new("Team",game.Teams) red.TeamColor = BrickColor.new("Bright red") red.Name = "Red Team" red.AutoAssignable = false local blue = Instance.new("Team",game.Teams) blue.TeamColor = BrickColor.new("Bright blue") blue.Name = "Blue Team" blue.AutoAssignable = false if game.Workspace.redteam.Value == game.Workspace.blueteam.Value then game.Workspace.random.Value = math.random(1,2) wait(.01) if game.Workspace.random.Value == 1 then player.TeamColor = BrickColor.new("Bright red") game.Workspace.redteam.Value = game.Workspace.redteam.Value +1 player.Character:BreakJoints() elseif game.Workspace.random.Value == 2 then player.TeamColor = BrickColor.new("Bright blue") game.Workspace.blueteam.Value = game.Workspace.blueteam.Value +1 player.Character:BreakJoints() if game.Workspace.redteam.Value >= game.Workspace.blueteam.Value then player.TeamColor = BrickColor.new("Bright red") player.Character:BreakJoints() game.Workspace.redteam.Value = game.Workspace.redteam.Value +1 elseif game.Workspace.redteam.Value <= game.Workspace.blueteam.Value then player.TeamColor = BrickColor.new("Bright blue") game.Workspace.blueteam.Value = game.Workspace.blueteam.Value +1 player.Character:BreakJoints() end end end end end end
|
|
|
| Report Abuse |
|
|
iHypered
|
  |
| Joined: 09 Nov 2010 |
| Total Posts: 2751 |
|
| |
|
|
| 14 Jul 2016 10:24 AM |
| Why are you not using variables... |
|
|
| Report Abuse |
|
|
iHypered
|
  |
| Joined: 09 Nov 2010 |
| Total Posts: 2751 |
|
|
| 14 Jul 2016 03:05 PM |
is that why it doesnt work right?
|
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 03:06 PM |
^No... but it would make it 1000x easier for us to fix if you used variables. It would also organize it and shorten it.
Star Wars Fans: https://www.roblox.com/games/345312845/- |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 03:09 PM |
| May i ask what is this suppozt to be,cuz i belive i could make it way shoreter ,even whitout variables,..? |
|
|
| Report Abuse |
|
|
iHypered
|
  |
| Joined: 09 Nov 2010 |
| Total Posts: 2751 |
|
|
| 14 Jul 2016 03:12 PM |
if Mode doesnt equal 3 then all players become team cyan and it kills them, if it does = 3 then it creates the teams blue and red and splits all the players into even teams
|
|
|
| Report Abuse |
|
|
iHypered
|
  |
| Joined: 09 Nov 2010 |
| Total Posts: 2751 |
|
|
| 14 Jul 2016 03:27 PM |
i just found on the wiki "rebalanceteams()", but it says its deprecated, is there anything similar to that which isnt deprecated, because thats pretty much what im trying to do except with 2 teams.
|
|
|
| Report Abuse |
|
|
iHypered
|
  |
| Joined: 09 Nov 2010 |
| Total Posts: 2751 |
|
| |
|
iHypered
|
  |
| Joined: 09 Nov 2010 |
| Total Posts: 2751 |
|
| |
|
iHypered
|
  |
| Joined: 09 Nov 2010 |
| Total Posts: 2751 |
|
| |
|
iHypered
|
  |
| Joined: 09 Nov 2010 |
| Total Posts: 2751 |
|
|
| 14 Jul 2016 04:05 PM |
someone please help, im trying to make balanced teams. it works but only for 1 player, and then continues the main game script, even though in:
for i, player in ipairs(game.Players:GetChildren()) do if player.Character then
it is supposed to do the stuff for all players
|
|
|
| Report Abuse |
|
|
iHypered
|
  |
| Joined: 09 Nov 2010 |
| Total Posts: 2751 |
|
| |
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 14 Jul 2016 05:02 PM |
for i,v in next, game.Players:GetPlayers() do if i%2 == 0 then v.Team = game.Teams['Red'] else v.Team = game.Teams['Blue'] end end
|
|
|
| Report Abuse |
|
|
iHypered
|
  |
| Joined: 09 Nov 2010 |
| Total Posts: 2751 |
|
|
| 14 Jul 2016 05:04 PM |
thanks so much, going to try it
|
|
|
| Report Abuse |
|
|
iHypered
|
  |
| Joined: 09 Nov 2010 |
| Total Posts: 2751 |
|
|
| 14 Jul 2016 05:14 PM |
everything works, thanks so much time
|
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 05:18 PM |
@OP I don't use ipairs because it stops when it hits a nil iteration; have you tried using pairs?
Now, look up in the upper-right corner of your screen, that red box there: that's the door. |
|
|
| Report Abuse |
|
|
iHypered
|
  |
| Joined: 09 Nov 2010 |
| Total Posts: 2751 |
|
|
| 14 Jul 2016 05:21 PM |
i dont really know how to use pairs, its confusing. the closest thing i know how to do is for loops. i got ipairs from the wiki for teleporting players. i just changed it a bit to try and get it to work for me
|
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 05:27 PM |
@OP They're both used (almost) exactly the same; as for example, in this code, you can just replace ipairs w/ pairs:
for i, v in pairs(tbl) do
for i, v in ipairs(tbl) do
Imo, there really isn't too much of a difference between the two, except that ipairs stops the iteration when it hits a nil iteration (in the table):
local tbl = { 1, 2, 3, nil, 5, 6 }
for i, v in ipairs(tbl) do print(v) -- Stops at 3 end
However, pairs will still proceed to go through the table, even though it hit a nil iteration; it appears to just skip the nil iteration, not return it, and proceed onto the next iteration of the table:
local tbl = { 1, nil, 3, nil, 5, 6 }
for i, v in pairs(tbl) do print(v) -- 1, 3, 5, 6 end
Now, look up in the upper-right corner of your screen, that red box there: that's the door. |
|
|
| Report Abuse |
|
|
iHypered
|
  |
| Joined: 09 Nov 2010 |
| Total Posts: 2751 |
|
|
| 14 Jul 2016 05:30 PM |
oh, thanks for explaining the difference, i didnt understand it.
|
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 05:34 PM |
@OP Np; you can continue to use ipairs if you want, I was just letting you know (and annoyingly informing) it stops the iteration when it hits nil. :)
Now, look up in the upper-right corner of your screen, that red box there: that's the door. |
|
|
| Report Abuse |
|
|
iHypered
|
  |
| Joined: 09 Nov 2010 |
| Total Posts: 2751 |
|
| |
|