Hello. First thing, This is a alt account if you are wondering why the bacon hair. Other words on to the issue.
First issue.
local teams = game:GetService("Teams") local tInfo = { ["Stalker"] = { MaxPlayers = 1; } ["Survivor"] = { MaxPlayers = 9; } ["Spectator"] = { MaxPlayers = 10; } } local function countTeam(team) local count = 0 for _, player in next, players:GetPlayers() do if player.Team == team then count = count + 1 end end return count end local function assignRandomTeam(player) local assigned = false while not assigned do local randomTeam = teams:GetChildren()[math.random(#teams:GetChildren())] if randomTeam and countTeam(randomTeam) < tInfo[randomTeam.Name].MaxPlayers then player.Team = randomTeam assigned = true end wait(.5) end end
Is the code i have to randomly select a player to a team. It was from a dev forum(Cant find it again). Also about how many people get in a team. When i run the command. It dose not randomize. it also gives me this error.
Workspace.Script Error 96,50 Expected ') (to close '{' at line 2),got '['
Also where do i place this. Do i keep it in the workshop or move it to a new file.
2 thing. Basically the title. i need some help creating a code that when a player joins a team they will be remodeled to a model i have.
Thank you.
Add commas to the first tables contents
local tInfo = { ["Stalker"] = { MaxPlayers = 1; }, ["Survivor"] = { MaxPlayers = 9; }, ["Spectator"] = { MaxPlayers = 10; } }
And for the random team replace it with
local randomTeam = teams:GetChildren()[math.random(1,#teams:GetChildren())]
Closed as Not Constructive by Nguyenlegiahung and killerbrenden
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?