Team assignment script

Hi! I’m unsure as to why this script isn’t working, any help would be greatly appreciated.

game.Players.PlayerAdded:Connect(function(newPlayer)
	local rank = newPlayer:GetRankInGroup(3517925)
	local teamName = "Customers"
	if rank >= 15 then
		teamName = "Senior-High Rank"
	elseif rank >= 9 then
		teamName = "Middle/High Rank"
	elseif rank >= 4 then
		teamName = "Low Rank"
	newPlayer.TeamColor = game.Teams[teamName].TeamColor
end)

Here is the edited version that should work!

game.Players.PlayerAdded:Connect(function(newPlayer)
local rank = newPlayer:GetRankInGroup(3517925)
local teamName = "Customers"
if rank >= 15 then
	teamName = "Senior-High Rank"
elseif rank >= 9 then
	teamName = "Middle/High Rank"
elseif rank >= 4 then
	teamName = "Low Rank"
newPlayer.Team = game.Teams[teamName]
end)

Still receiving the same error as before.

ServerScriptService.Team Assignment:11: Expected identifier when parsing expression, got ')'

forgot and end here is the updated:

game.Players.PlayerAdded:Connect(function(newPlayer)
local rank = newPlayer:GetRankInGroup(3517925)
local teamName = "Customers"
if rank >= 15 then
teamName = "Senior-High Rank"
elseif rank >= 9 then
teamName = "Middle/High Rank"
elseif rank >= 4 then
teamName = "Low Rank"
end
newPlayer.Team = game.Teams[teamName]

end)
1 Like