Setting Players' Name Inside a Value while Players are in a Specific Team?
Asked by
7 years ago Edited 7 years ago
Basically what I'm trying to do is that if players are on a team, I want them to have their own individual stringvalue. These values are in ServerStorage.
01 | for i, v in pairs (game.Players:GetPlayers()) do |
02 | local hometeam = game.Teams.Home |
03 | local awayteam = game.Teams.Away |
04 | local homeplayers 1 = hometeam:GetPlayers() |
05 | local awayplayers 1 = awayteam:GetPlayers() |
06 | if v.Team = = hometeam then |
07 | local C 1 = homeplayers 1 [ math.random( 1 , #homeplayers 1 ) ] |
08 | local C 2 = homeplayers 1 [ math.random( 1 , #homeplayers 1 ) ] |
09 | local C 3 = homeplayers 1 [ math.random( 1 , #homeplayers 1 ) ] |
10 | local C 4 = homeplayers 1 [ math.random( 1 , #homeplayers 1 ) ] |
11 | local P 1 = HomePlayers:WaitForChild( "Player1" ) |
12 | local P 2 = HomePlayers:WaitForChild( "Player2" ) |
13 | local P 3 = HomePlayers:WaitForChild( "Player3" ) |
14 | local P 4 = HomePlayers:WaitForChild( "Player4" ) |
15 | if #homeplayers 1 > 0 then |
16 | repeat C 2 = homeplayers 1 [ math.random( 1 , #homeplayers 1 ) ] until C 2 ~ = C 1 |
17 | and C 2 ~ = C 3 and C 2 ~ = C 4 wait() |
18 | if #homeplayers 1 = = 3 then |
19 | repeat C 3 = homeplayers 1 [ math.random( 1 , #homeplayers 1 ) ] until C 3 ~ = C 1 |
20 | and C 3 ~ = C 2 and C 3 ~ = C 4 wait() |
21 | if #homeplayers 1 = = 4 then |
22 | repeat C 4 = homeplayers 1 [ math.random( 1 , #homeplayers 1 ) ] until C 4 ~ = C 1 |
23 | and C 4 ~ = C 3 and C 4 ~ = C 2 wait() |
31 | elseif v.Team = = awayteam then |
32 | local C 1 = awayplayers 1 [ math.random( 1 , #awayplayers 1 ) ] |
33 | local C 2 = awayplayers 1 [ math.random( 1 , #awayplayers 1 ) ] |
34 | local C 3 = awayplayers 1 [ math.random( 1 , #awayplayers 1 ) ] |
35 | local C 4 = awayplayers 1 [ math.random( 1 , #awayplayers 1 ) ] |
36 | local P 1 = AwayPlayers:WaitForChild( "Player1" ) |
37 | local P 2 = AwayPlayers:WaitForChild( "Player2" ) |
38 | local P 3 = AwayPlayers:WaitForChild( "Player3" ) |
39 | local P 4 = AwayPlayers:WaitForChild( "Player4" ) |
40 | if #awayplayers 1 > 0 then |
41 | repeat C 2 = awayplayers 1 [ math.random( 1 , #awayplayers 1 ) ] until C 2 ~ = C 1 |
42 | and C 2 ~ = C 3 and C 2 ~ = C 4 wait() |
43 | if #awayplayers 1 = = 3 then |
44 | repeat C 3 = awayplayers 1 [ math.random( 1 , #awayplayers 1 ) ] until C 3 ~ = C 1 |
45 | and C 3 ~ = C 2 and C 3 ~ = C 4 wait() |
46 | if #awayplayers 1 = = 4 then |
47 | repeat C 4 = awayplayers 1 [ math.random( 1 , #awayplayers 1 ) ] until C 4 ~ = C 1 |
48 | and C 4 ~ = C 3 and C 4 ~ = C 2 wait() |
Thanks,
LukeGabrieI
[Apparently this script is passed, I haven't gotten any errors, but it doesn't work.]