Hi there! This player picker picks the blue team num1 and num2 but then doesn't put the rest of the players in the green team. I also think there might be another cause. Any ideas? Thanks :)
id = 186964027 list = {} function AddPlayers() for i,v in pairs (game.Players:GetChildren()) do table.insert(list,v) if game:GetService("GamePassService"):PlayerHasPass(v,id) then table.insert(list,v) end end num1 = math.random(1,#list) --Number num1 = list[num1] -- Value from the table num1.TeamColor = BrickColor.Blue() num2 = math.random(1,#list) --Number num2 = list[num2] -- Value from the table print(num1) print(num2) if num2.Name == num1.Name then repeat num2 = math.random(1,#list) num2 = list[num2] num2.TeamColor = BrickColor.Blue() until num2.Name ~= num1.Name for i,v in pairs (list) do if v.Name ~= num1.Name and v.Name ~= num2.Name then v.TeamColor = BrickColor.new("Bright green") end end end end
You didn't call the function, a function needs to be called for it to work. For example, if someone needed to touch something, you would put this after your script:
script.Parent.Touched:connect(AddPlayers) -- in the parentheses, you put the function name
If you are going to do this, make sure the script is in a brick
I am calling the function but I just haven't shown it here :(