Yorixk
|
  |
| Joined: 15 Feb 2015 |
| Total Posts: 606 |
|
|
| 28 Jun 2017 06:07 PM |
Paying 1,000 R$ for a block of code which will be placed inside my script to switch players' teams from the "Lobby" team, to the "Red" or "Blue" team.
The teams should also be balanced.
My current code chooses a random map and then teleports users from the "Lobby" team onto the two spawns on the map. The problem is, it randomly spawns the players, which makes the teams unbalanced.
PASTEBIN: /SjvdXnpj
|
|
|
| Report Abuse |
|
|
|
| 28 Jun 2017 06:14 PM |
local colors={game.Teams.Red.TeamColor, game.Teams.Blue.TeamColor} for i,v in ipairs(game.Players:GetPlayers())do if v.TeamColor == game.Teams.Lobby.TeamColor then v.TeamColor=BrickColor.new(colors[(i-1)%#colors+1]) end end |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 28 Jun 2017 06:20 PM |
local players = game.Players:GetPlayers() for i=1, #players do local player = table.remove(players, math.random(#players)) local character = player.Character if character then character:MoveTo(spawns[i%#spawns + 1].Position) end end |
|
|
| Report Abuse |
|
|
Yorixk
|
  |
| Joined: 15 Feb 2015 |
| Total Posts: 606 |
|
|
| 28 Jun 2017 06:32 PM |
^ I put your code under mine, or swap yours with mine?
|
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
| |
|
Yorixk
|
  |
| Joined: 15 Feb 2015 |
| Total Posts: 606 |
|
|
| 28 Jun 2017 06:46 PM |
16:46:29.247 - ServerScriptService.MainScript:35: attempt to get length of global 'spawns' (a nil value)
|
|
|
| Report Abuse |
|
|
|
| 28 Jun 2017 06:47 PM |
boi.
You have to put the name and place of ur spawns |
|
|
| Report Abuse |
|
|
Yorixk
|
  |
| Joined: 15 Feb 2015 |
| Total Posts: 606 |
|
|
| 28 Jun 2017 06:56 PM |
Hm. I just added the new SpawnLocation spawns instead of regular brick spawns, and it broke the system. When you enter the game in the "Lobby" team, you don't spawn on your designated spawn.
|
|
|
| Report Abuse |
|
|
Yorixk
|
  |
| Joined: 15 Feb 2015 |
| Total Posts: 606 |
|
|
| 28 Jun 2017 06:59 PM |
What is causing this? I spawn in the air and not on the "Lobby" spawns, even though I am on the "Lobby" team.
|
|
|
| Report Abuse |
|
|