Auto team without lag

Hello,
I have a few methods to auto teaming but they have been super laggy. Can someone help me out a bit?

Did you not read how to post a topic?
What are trying to achieve?
What is the issue?

We can’t help you if you don’t tell us, so please do.

1 Like

I am trying to use something like this
game.Players.PlayerAdded:Connect(function(player)
if player:IsInGroup(6469543)then
if player:GetRankInGroup(GroupId) >= 12-255 then
player.TeamColor = Blue BrickColor.new(“team color”)
elseif player:GetRankInGroup( 6469543) >= 3-11 then
player.TeamColor = Red BrickColor.new(“team color”)
end
end
end)
I am trying to make the script less lag and trying to fix any errors

What you could do is store the player’s rank in a variable instead. After that, combine some conditional statements.

game.Players.PlayerAdded:Connect(function(player)
    local Rank = player:GetRankInGroup(6469543)
    if player:IsInGroup(6469543)then
        if Rank >= 12 and Rank <= 255 then
            -- greater than 12, less than 255
            player.TeamColor = BrickColor.new(“Red”)
        elseif Rank >= 3 and Rank <= 11
            -- greater than 3, less than 11
            player.TeamColor = BrickColor.new(“Blue”)
        end
    end
end)
2 Likes

Would I put that in sever script storage or workspace or chat?

Depends on how you would want to Player’s TeamColor to change.

To clarify also possibly equal to 12 or equal to 255.

Here’s that code shortened to an extent where readability isn’t harmed too much, just in case any one needs it (no significant difference from using if statements)

game.Players.PlayerAdded:Connect(function(player)
    local rank = player:GetRankInGroup(6469543)
    if rank ~= 0 then 
        player.TeamColor =  ((rank>=12 and rank<=255) and BrickColor.new("Red")) or ((rank>=3 and rank<=11) and BrickColor.new("Blue")) or BrickColor.new("Green") -- people without specified ranks have their TeamColor = Green
    end
end)
1 Like

So am I able to make it chat color? lol

For chat color, you can look at the Lua Chat System to know how to change a person’s chat color. By default, your chat color is your team color.