Group Rank Team Changer

Hello, I’m new to scripting and I want to make it so you’re able to click on a button that is in a Frame and it switches your team! Only if you are in the Group.
Example:
You click the button, you get changed to: "US Army".
You must be in the group at a minium group rank to be teamed.
Please also tell me the location for main script, but, I would assume it goes in workspace?
And then there of course has to be a script in the Button, or else it wouldn’t fire a Remote if you clicked it…

Roblox has built in :IsInGroup() function for this very reason of being able to have different asthetics/custom items in games.

For Example:

    game.Players.PlayerAdded:Connect(function(newPlayer)
       if newPlayer:IsInGroup(7) then                    
          print('player in group')
       else    
         print('not in group')
       end
    end)

You can the connect this function to Instead of game.Players.PlayerAdded:Connect(function() to once the TextButton is clicked

TextButton.MouseButton1Clicked:Connect(function(newPlayer)
 if newPlayer:IsInGroup(7) then                    
          print('player in group')
       else    
         print('not in group')
       end
    end)

Nope, it won’t go into workspace. Instead it’ll go into the button as a LocalScript.


I’d recommend firing a remote when the button is clicked and the server will check if the user’s rank then set their team.

So the Local Script inside the button would receive the User’s rank/group? Also would there be a script inside the button just to fire the Remote?

I know, I thought of that. I have that down basically, just I don’t know if it should be a Script, or local script. I assume a script, also I don’t know how to set a Players team… That’s my main issue. Unless there’s some open-source admin that I can look through and paste that.

Nope, the only thing that the server will get from the remote will be the client and use the GetRankInGroup function to get their rank.

I don’t really get how you want this system to be like by group or a rank.

Server Sided {Normal Script}, client sided scripts I don’t think will be able to get the rank information

Okay, I’ll give an example of the system, give me a second.

This is based iff @ooxyDev 's solution, but it changes the team.

local GroupId = -- Insert group ID here
local TeamName = -- Insert the name of the team that the player will be on if they are in the group.
    game.Players.PlayerAdded:Connect(function(newPlayer)
       if newPlayer:IsInGroup(GroupId) then                    
          newPlayer.Team = game:GetService("Teams")[TeamName]
       else    
         print('not in group')
       end
    end)

Player joins game, opens the menu, clicks US Army button.
The local script would check if their in the Group, and att the certain rank, EX: Rank 2, US Army(Group). If their in the group at the min. rank then, then, a event will be fired and it will team them on the team.

I know that, I have basically the same script like that. But, my issue is, I want it to be a Team Color, not the name since it has a space, Number 2, I want them to be atleast rank 2 for example. My main issue:
I can’t find out how to make it a TEAM COLOR to change, and I’m not able to find how to make it so it has to be a min. rank.

Let me try to explain more clearly.


When a player clicks the button (using a MouseButton1Click or Activated event) a RemoteEvent to the server will be fired.

The remote would check if their inside a group, if they are then it will change the user’s team.

button.Activated:Connect(function()
remote:FireServer()
end)
remote.OnServerEvent:Connect(function(player)
if player:IsInGroup(groupId) then
-- give team to player
end
end)

Also the reason why the LocalScript wouldn’t check their group is because exploiters can easily fire the remote without any detection.

[ Correct me if I’m wrong ]

1 Like