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.
for i, v in pairs(game.Players:GetPlayers()) do
local hometeam = game.Teams.Home
local awayteam = game.Teams.Away
local homeplayers1 = hometeam:GetPlayers()
local awayplayers1 = awayteam:GetPlayers()
if v.Team == hometeam then
local C1 = homeplayers1[math.random(1, #homeplayers1)]
local C2 = homeplayers1[math.random(1, #homeplayers1)]
local C3 = homeplayers1[math.random(1, #homeplayers1)]
local C4 = homeplayers1[math.random(1, #homeplayers1)]
local P1 = HomePlayers:WaitForChild("Player1")
local P2 = HomePlayers:WaitForChild("Player2")
local P3 = HomePlayers:WaitForChild("Player3")
local P4 = HomePlayers:WaitForChild("Player4")
if #homeplayers1 > 0 then
repeat C2 = homeplayers1[math.random(1, #homeplayers1)] until C2 ~= C1
and C2 ~= C3 and C2 ~= C4 wait()
if #homeplayers1 == 3 then
repeat C3 = homeplayers1[math.random(1, #homeplayers1)] until C3 ~= C1
and C3 ~= C2 and C3 ~= C4 wait()
if #homeplayers1 == 4 then
repeat C4 = homeplayers1[math.random(1, #homeplayers1)] until C4 ~= C1
and C4 ~= C3 and C4 ~= C2 wait()
end
end
end
P1.Value = C1.Name
P2.Value = C2.Name
P3.Value = C3.Name
P4.Value = C4.Name
elseif v.Team == awayteam then
local C1 = awayplayers1[math.random(1, #awayplayers1)]
local C2 = awayplayers1[math.random(1, #awayplayers1)]
local C3 = awayplayers1[math.random(1, #awayplayers1)]
local C4 = awayplayers1[math.random(1, #awayplayers1)]
local P1 = AwayPlayers:WaitForChild("Player1")
local P2 = AwayPlayers:WaitForChild("Player2")
local P3 = AwayPlayers:WaitForChild("Player3")
local P4 = AwayPlayers:WaitForChild("Player4")
if #awayplayers1 > 0 then
repeat C2 = awayplayers1[math.random(1, #awayplayers1)] until C2 ~= C1
and C2 ~= C3 and C2 ~= C4 wait()
if #awayplayers1 == 3 then
repeat C3 = awayplayers1[math.random(1, #awayplayers1)] until C3 ~= C1
and C3 ~= C2 and C3 ~= C4 wait()
if #awayplayers1 == 4 then
repeat C4 = awayplayers1[math.random(1, #awayplayers1)] until C4 ~= C1
and C4 ~= C3 and C4 ~= C2 wait()
end
end
end
P1.Value = C1.Name
P2.Value = C2.Name
P3.Value = C3.Name
P4.Value = C4.Name
end
end
Thanks,
LukeGabrieI
[Apparently this script is passed, I haven't gotten any errors, but it doesn't work.]

3 comments
*StringValue:Clone().Parent =
this wouldn't work since I'm trying to accomplish something else after
I'm also using filtering Enabled lol, so anything locally won't be cloned