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

This auto team script does not team anyong besides models. Would love some help (Should be easy?)

game.Players.PlayerAdded:connect(function(player)
	if player:GetRankInGroup(2533886) == 8 then
		player.TeamColor = game.Teams.Security.TeamColor
	else
	if player:GetRankInGroup(2533886) >= 1 then
	player.TeamColor = game.Teams.Models.TeamColor
	else		
			game.Players.PlayerAdded:connect(function(player)
	if player:GetRankInGroup(2533886) <= 0 then
		player.TeamColor = game.Teams.Spectators.TeamColor
	else
				game.Players.PlayerAdded:connect(function(player)
	if player:GetRankInGroup(2533886) >= 12 then
		player.TeamColor = game.Teams.HighRanks.TeamColor 
		
	end
		end)

	end
		end)

	end
		end
end)


3 comments

0

High ranks dont work

0

Those ends are uneccesary. You don't have to seperate 'else' and 'if', put it together like 'elseif player:GetRankInGroup(2533886) == 8 then ..'

0

Will that fix it

1 answer

You must format your code correctly so that your code is readable. Otherwise, you'll have no idea what you're writing:

game.Players.PlayerAdded:connect(function(player)
        if player:GetRankInGroup(2533886) == 8 then
                player.TeamColor = game.Teams.Security.TeamColor
        else
                if player:GetRankInGroup(2533886) >= 1 then
                        player.TeamColor = game.Teams.Models.TeamColor
                else
                        game.Players.PlayerAdded:connect(function(player)
                                if player:GetRankInGroup(2533886) <= 0 then
                                        player.TeamColor = game.Teams.Spectators.TeamColor
                                else
                                        game.Players.PlayerAdded:connect(function(player)
                                                if player:GetRankInGroup(2533886) >= 12 then
                                                        player.TeamColor = game.Teams.HighRanks.TeamColor
                                                end
                                        end)
                                end
                        end)
                end
        end
end)

This "pyramid" look is not a good sign. Having :Connections inside :Connections is not a good sign.

Right now, if you just read what your code does, you only start waiting for rank 12s and beyond AFTER

  • a rank not 8 joins
  • then a rank 0 joins
  • then a rank not 0 joins

Use either separate :Connections for each rank, or more simply, an if...elseif chain inside a single :Connect handler

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