Hey, i've attempted at a script to create two teams then randomly assign players to teams. Currently i tried to make it so that it creates a NumberValue in every player then randomly generates a number between 1 and 2 and if its 1 your on team A if 2 team B. Heres my script.
P = game.Players:GetPlayers() E = Instance.new("NumberValue") E.Parent = game.Players:GetPlayers() E.Value = math.random(1,2) if E.Value == 1 then E.Parent.Parent.Team = game.Teams.Guards end if E.Value == 2 then E.Parent.Parent.Team = game.Teams.Theives end
BTW this is the section of the script that doesnt work, creating the teams works fine. Returns error "Expected Object got Table" probably caused by me trying to put a Instance in a table, but im not sure how to fix this.
Thanks! -Sir
players = game.Players:GetChildren() teams = {"Bright blue","Bright red"} num = 1 for i,v in pairs(players) do v.TeamColor = BrickColor.new(teams[num]) num = num + 1 if num > #teams then num = 1 end end
The above will sort two teams out and give them either blue or red team.
Now you want a team with guards and thieves. Just put this is at the same point you had yours, then make 2 teams in the folder, 1 bright blue, 1 bright red, then rename the team names to Guards/Thieves.
If this dosent work then please tell me and I will look over and see if I got anything wrong. If this did help then remember to upvote and accept answer for others to see if they have the same problem.