Chubs1995
|
  |
| Joined: 02 Sep 2007 |
| Total Posts: 339 |
|
|
| 07 May 2014 10:19 PM |
I want this to assign a player to a team when the brick is clicked. I'm pretty sure a script can't have two functions so I'm confused on how to fix that.
function h(hit)
function teamScrambler() local players = {} local team1 = {} local team2 = {} local p = game.Players:GetChildren() for i = 1, #p do table.insert(players, p[i]) end for i = 1, #players do local randomPlayer = math.random(1, #players) local chosenPlayer = players[randomPlayer] if #team1 == #team2 then local ran = math.random(1, 2) if ran == 1 then chosenPlayer.TeamColor = BrickColor.new("Cyan") table.insert(team1, chosenPlayer) else chosenPlayer.TeamColor = BrickColor.new("Bright red") table.insert(team2, chosenPlayer) end elseif #team1 > #team2 then chosenPlayer.TeamColor = BrickColor.new("Bright red") table.insert(team2, chosenPlayer) elseif #team1 < #team2 then chosenPlayer.TeamColor = BrickColor.new("Cyan") table.insert(team1, chosenPlayer) end table.remove(players, randomPlayer) end end
end script.Parent.ClickDetector.MouseClick:connect(h) |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 07 May 2014 10:20 PM |
| A script can have 2 functions... |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 07 May 2014 10:21 PM |
Correction What I meant was it can have however many you want. Sorry. |
|
|
| Report Abuse |
|
|
Chubs1995
|
  |
| Joined: 02 Sep 2007 |
| Total Posts: 339 |
|
|
| 07 May 2014 10:21 PM |
| Then why isn't this script working? |
|
|
| Report Abuse |
|
|
Chubs1995
|
  |
| Joined: 02 Sep 2007 |
| Total Posts: 339 |
|
| |
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 07 May 2014 10:41 PM |
What does the output say and what are you trying to do?
This? http://wiki.roblox.com/index.php/RebalanceTeams_(Method) |
|
|
| Report Abuse |
|
|
Chubs1995
|
  |
| Joined: 02 Sep 2007 |
| Total Posts: 339 |
|
|
| 08 May 2014 02:36 AM |
| The output doesn't tell me anything regarding the script. I want to make it so that when a player clicks a brick, they are randomized onto a team. I have 4 teams, but only 2 of which are the teams that I want players to be randomized onto. The link you provided will balance the teams, but only across all teams. That's not what I want. I want two of the four teams balanced. |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 08 May 2014 09:41 AM |
You are making this a lot harder than it needs to be .-.
function OnClick(Player) Team = math.random(0, 1) if Team == 0 then Player.TeamColor = BrickColor.new("Bright blue") elseif Team == 1 then Player.TeamColor = BrickColor.new("Bright red") end end |
|
|
| Report Abuse |
|
|
Chubs1995
|
  |
| Joined: 02 Sep 2007 |
| Total Posts: 339 |
|
| |
|
Chubs1995
|
  |
| Joined: 02 Sep 2007 |
| Total Posts: 339 |
|
| |
|
|
| 12 May 2014 06:21 PM |
script.Parent.MouseClick:connect(function(p) local random = math.random(1,2) if random == 1 then p.TeamColor = BrickColor.new("Bright red") else p.TeamColor = BrickColor.new("Bright blue") end end) |
|
|
| Report Abuse |
|
|
Chubs1995
|
  |
| Joined: 02 Sep 2007 |
| Total Posts: 339 |
|
|
| 12 May 2014 06:28 PM |
| That didn't work either. :/ |
|
|
| Report Abuse |
|
|
Chubs1995
|
  |
| Joined: 02 Sep 2007 |
| Total Posts: 339 |
|
| |
|
Chubs1995
|
  |
| Joined: 02 Sep 2007 |
| Total Posts: 339 |
|
| |
|
Chubs1995
|
  |
| Joined: 02 Sep 2007 |
| Total Posts: 339 |
|
| |
|
Chubs1995
|
  |
| Joined: 02 Sep 2007 |
| Total Posts: 339 |
|
|
| 14 May 2014 01:18 PM |
| Still need help, people..... |
|
|
| Report Abuse |
|
|
Chubs1995
|
  |
| Joined: 02 Sep 2007 |
| Total Posts: 339 |
|
| |
|
| |
|
Chubs1995
|
  |
| Joined: 02 Sep 2007 |
| Total Posts: 339 |
|
| |
|
Chubs1995
|
  |
| Joined: 02 Sep 2007 |
| Total Posts: 339 |
|
| |
|
youssef04
|
  |
| Joined: 22 Jan 2011 |
| Total Posts: 1745 |
|
|
| 17 May 2014 03:02 PM |
script.Parent.MouseClick:connect(function(p) -- Is this script in the ClickDetector, if not, put in there for it to work local random = math.random(1,2) if random == 1 then p.TeamColor = BrickColor.new("Bright red") else p.TeamColor = BrickColor.new("Bright blue") end end) |
|
|
| Report Abuse |
|
|
Chubs1995
|
  |
| Joined: 02 Sep 2007 |
| Total Posts: 339 |
|
| |
|