Group Team Changer GUI

I’m currently working on a team changer GUI button. The issue is I don’t know how to script, I’ve tried searching up how to make a group team changer but I can’t find any good solution how to make one. I’ve tried using this script:


lcoal MinimalRank = 1
game.Players.PlayerAdded:Connect(function(Player)
    if Player:GetRankInGroup(GroupId) >= MinimalRank then
        -- Change players team
    else
        -- Don't change players team.
    end
end)


I want the user to join the group to get on the Police Team.

To change the player’s team, I would use something along the lines of Player.TeamColor = BrickColor.new("Bright blue").

Your code should look something like this.

local GroupId = 1 -- Change this to your group id.
local MinimalRank = 1 -- You misspelled local. Fixed it for you.
local Police = BrickColor.new("Bright blue") -- Change the team color.
game.Players.PlayerAdded:Connect(function(Player)
    if Player:GetRankInGroup(GroupId) >= MinimalRank then
        Player.TeamColor = Police
    else
        -- Don't change players team.
    end
end)

Note that the code above only changes your team once you join.

You could make a button then add a script

script.Parent.MouseButton1Down

And check if a player is in a group then if they are then they will be teamed to Police

plr.Team = game.Teams.Police

To create a team changer then you will have to use Player.Team, define team and the player which is going to Police Team. Here is an example:

local MinimalRank = 1
local TeamPolice = game:GetService("Teams").TeamPolice --Change this to your team name

game.Players.PlayerAdded:Connect(function(Player)
    if Player:GetRankInGroup(GroupId) >= MinimalRank then
        Player.Team = TeamPolice 
        -- To change the colour you have to use player.TeamColor property
    else
        -- Don't change players team.
    end
end)
2 Likes