How i Weld a Group to A Team changer?

Hello, I had a problem when developing my SCPF genre game, The serious problem, I had a “Team Changer” command and I already have the groups made in Roblox and in the game, and I want to connect those options to the Team Changer to A real group in Roblox, for example. If I try to Select the “Administrative Department” option, it will only work if I am in a certain group.
The problem is that I do not know how to connect a group to a team changer.
These would be photos of what I have done.
This is the team changer image

This is the team’s Script

	["Class-D"] = {0,0 ,BrickColor.new("Bright orange")},
	["Foundation Personnel"] = {0,0 ,BrickColor.new("Ghost grey")},
	["Scientific Department"] = {0,0 ,BrickColor.new("Bright blue")},
	["Security Department"] = {0,0 ,BrickColor.new("Bright blue")},
	["Medical Department"] = {0,0 ,BrickColor.new("Smoky grey")},
	["Manufacturing Department"] = {0,0 ,BrickColor.new("Deep orange")},
	["Mobile Task Force"] = {0,0 ,BrickColor.new("Navy blue")},
	["Phantom"] = {0,0 ,BrickColor.new("Really black")},
	["Internal Security Department"] = {0,0 ,BrickColor.new("Dusty Rose")},
	["Intelligence Agency"] = {0,0 ,BrickColor.new("Crimson")},
	["Engineering & Technical Service"] = {0,0 ,BrickColor.new("Cool yellow")},
	["Administrative Department"] = {0,0 ,BrickColor.new("Maroon")},
	["Chaos Insurgency"] = {0,0 ,BrickColor.new("Black")},
	

}

return module

This is the Team Changer Main Script.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TeamsModule = require(ReplicatedStorage:WaitForChild("TeamsModule"))
local ChangeEvent = ReplicatedStorage:WaitForChild("TeamChange")

local GUI = script.Parent
local OpenButton = GUI:WaitForChild("OpenChanger")
local Changer = GUI:WaitForChild("Changer")
local TeamList = Changer:WaitForChild("TeamList")
local opened = false
local debounce = false
wait()

function Open()
	if not debounce then
		if not opened then
			debounce = true
			OpenButton.Text = "<"
			Changer:TweenPosition(UDim2.new(0.5,-150,0.5,-200),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.5)
			wait(.5)
			opened = true
			debounce = false
		else
			debounce = true
			OpenButton.Text = ">"
			Changer:TweenPosition(UDim2.new(0.5,-1500,0.5,-200),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.5)
			wait(.5)
			opened = false
			debounce = false
		end
	end
end

local buttons = 0
for n,team in pairs(TeamsModule) do
	if player:GetRankInGroup(team[1]) >= team[2] or player.UserId == 4409841 then
		format = script.Format:Clone()
		format.Parent = TeamList
		format.Name = n
		format.Text = n
		buttons = buttons + 1
	end
end
local slotSize = 50 + 5
local canY = slotSize * buttons
TeamList.CanvasSize = UDim2.new(0,0,0,canY)

AvailableTeams = TeamList:GetChildren()
for a = 1,#AvailableTeams do
	if AvailableTeams[a].ClassName == "TextButton" then
		AvailableTeams[a].MouseButton1Down:connect(function(ChangeTeam)
			for i,v in pairs(TeamsModule) do
				if AvailableTeams[a].Name == i then
					ChangeEvent:FireServer(v[3])
				end
			end
		end)
	end
end

OpenButton.MouseButton1Down:Connect(Open)

I give this information for have more Details about the issue.

Short Answer


You can use Player:IsInGroup(yourGroupId) in order to check if they are in the group. yourGroupId is the ID to the respective group you want to limit the changer to.

Let’s say that you have the group ID of 1337. The following will look like this…
Example:

SomeRandomRemote.OnServerEvent:Connect(function(player)
	if player:IsInGroup(1337) then
		-- do something if they are in group, also I'm feeling lazy to read your script hahaha
	end
end)
2 Likes

Oh, Thanks! I will try it, I advise you if I have any issue.

But, Where i put that script, Sorry for the basic questions, I’am not Scripter.

I put the Script in the Comamnd “TeamsModule” or In The Command “Main” The “Main” Are the Big command And the TeamsModule, Are the Thing that makes the Teams appear in the Teams GUI

A little further reading confirms that in the tables:
["Class-D"] = {0, 0,BrickColor.new("Bright orange")}

…reveals that the first number is for group ID.
player:GetRankInGroup(team[1])

Not sure about the team[2], whatever the second index’s purpose is.

Uhhh… What do you mean?
So
In the part of image
Do i have to put this script? player:GetRankInGroup(team[1])
Or
The part of the numbers image i have to put the Script player:GetRankInGroup(team[1])?
Mhm…

Wow, I feel silly for asking you so basic questions, I’m sorry for so many questions, only that I find it hard to understand.

Change the first 0 into the group ID you wish to fill it with. Unfortunately, I cannot determine exactly what script.Format is.

Target


The target is in this block.

AvailableTeams = TeamList:GetChildren()
for a = 1,#AvailableTeams do
	if AvailableTeams[a].ClassName == "TextButton" then
		AvailableTeams[a].MouseButton1Down:connect(function(ChangeTeam)
			for i,v in pairs(TeamsModule) do
				if AvailableTeams[a].Name == i then
					ChangeEvent:FireServer(v[3])
				end
			end
		end)
	end
end

Changed to this:

AvailableTeams = TeamList:GetChildren()
for a = 1,#AvailableTeams do
	if AvailableTeams[a]:IsA("TextButton") then
		AvailableTeams[a].MouseButton1Down:Connect(function() -- ChangeTeam removed
			for i, v in pairs(TeamsModule) do
				if AvailableTeams[a].Name == i and player:IsInGroup(v[1]) then
					ChangeEvent:FireServer(v[3])
				end
			end
		end)
	end
end
2 Likes