How do i make players get a random team?
local teamColors = {BrickColor.new("Bright red"), BrickColor.new("Bright blue")} for i, user in pairs(game:GetService("Players"):GetPlayers()) do if math.random(1, 2) == 1 then user.TeamColor = BrickColor.new('Bright blue') else user.TeamColor = BrickColor.new('Bright red') end end
Problem
You want to make a player get a random team
Solution
Use the PlayerAdded
function to work this out with each joining player. Also remove the teamColors
array because it seems to not be in use.
Final Script
--Function function PlayerAdded(user) if math.random(1, 2) == 1 then user.TeamColor = BrickColor.new('Bright blue') else user.TeamColor = BrickColor.new('Bright red') end end game:GetService('Players').PlayerAdded:connect(PlayerAdded) --Since studio changed the way PlayerAdded works, put these lines to make it work in Solo mode for i, user in ipairs(game:GetService('Players'):GetPlayers()) do PlayerAdded(user) end