Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Team ranking system script isn't working any ideas why?

game.Players.PlayerAdded:connect(function(plar)
	if plar:IsInGroup(3072854) then
		if plar:GetRankInGroup(3072854) >= 254 then
			plar.TeamColor = "Dark stone grey"
		else plar.TeamColor = "Medium stone grey"
		end
		else plar.TeamColor = "Bright green"
	end
end)

1 answer

✓ Accepted answer

One of the problems is that you are comparing a BrickColor with a string.

print(BrickColor.new('White') == 'White')

This will print false.

You will need to either compare the name or the object e.g.

print(BrickColor.new('White') == BrickColor.new('White'))

-- or
print(BrickColor.new('White').Name == 'White')

Both methods will work

The second problem is that you cannot change the players team by setting the TeamColor. To change the team you can set the Team of the player to another Team object e.g:-

local tmSrv = game:GetService('Teams')

local blue = Instance.new('Team', tmSrv)
blue.TeamColor = BrickColor.new('Dark blue')
blue.AutoAssignable = false

local green = Instance.new('Team', tmSrv)
green.TeamColor = BrickColor.new('Lime green')
green.AutoAssignable = false

local teamList = {blue, green}
local teamCount = #teamList

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(charModel)
		-- randomly changes the team
		plr.TeamColor = teamList[math.random(teamCount)].TeamColor
	end)
end)

I hope this helps.

This discussion is preserved as it was. New answers, comments, and votes are closed.