Team changer GUI help, check group table before creating team clone

Basically, I want this to check the player groups from the table and make sure they are in them before
creating the new team clone. This is being used for a team changer gui… and I just dont want people to be able to see each team unless they are in the groups in the table. Not really sure how to go about attack this I know how to get the players group role/rank and everything but not sure how would It actually look telling the script to check all instances in the table before cloning.

local groups = { 
	Westerosi = 12502458,
	Vhegaria = 33941379,
	"Bloodline of Vhegaria" == 7825194
}


default = script.Parent.Default:Clone()
shift=0
for i,v in game:GetService("Teams"):GetChildren() do
	newteam = default:Clone()
	newteam.Parent = script.Parent
	newteam.Visible=true
	newteam.TeamName.Text = v.Name
end
1 Like

maybe some thing likeee…

if Teams.TeamName == player:GetRoleInGroups(groups) then

1 Like

or this if game.Players:GetRoleInGroups(groups{}) == game.Teams.TeamName then

1 Like
if game.Players:IsInGroup(table[1])  and
	game.Teams.TeamName == (table[1]) then

Closer to what I wanna do still not getting it right though…

1 Like

If I change the table to


local groups {

[1] { groupid = 000000,
groupid2 = 000000

}

[2] { (“Vhegaria”,”Blahblah”)

}

    • get team service and blah blah blah here

if game.Players:IsInGroup(table[1]) and
game.Teams.TeamName == tostring(table[2]) then

- - enter code here

Would something like this work?

1 Like

Or just Teams cause I’m finding a string in the table?

1 Like

local groups = {
Westerosi = 12502458,
Vhegaria = 33941379,
“Bloodline of Vhegaria” == 7825194
}

default = script.Parent.Default:Clone()
shift=0
for i,v in game:GetService(“Teams”):GetChildren() do
If game.Players.LocalPlayer:IsInGroup(groups.Westerosi) then
newteam = default:Clone()
newteam.Parent = script.Parent
newteam.Visible=true
newteam.TeamName.Text = Westerosi
elseif game.Players.LocalPlayer:IsInGroup(groups.Vhegaria) then
newteam = default:Clone()
newteam.Parent = script.Parent
newteam.Visible=true
newteam.TeamName.Text = Vhegaria
end
end

1 Like

Check if they are in the group using the dictionary.

Code:

-- Services
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")

-- Variables
local LocalPlayer = Players.LocalPlayer
local template = script.Parent.Default

-- Tables
local groups = {
	Westerosi = 12502458,
	Vhegaria = 33941379,
	["Bloodline of Vhegaria"] = 7825194
}

-- Functions
for _, team in Teams:GetTeams() do
	local teamName = team.Name
	
	if LocalPlayer:IsInGroup(groups[teamName]) then
		local newButton = template:Clone()
		newButton.TeamName.Text = teamName
		newButton.Visible = true
		newButton.Parent = script.Parent
	end
end
1 Like

Thankkk youuuu will try this out right away

1 Like

nothing showing up still

works with this just doesn’t check for the groups first

default = script.Parent.Default:Clone()
shift=0
for i,v in game:GetService("Teams"):GetChildren() do
	newteam = default:Clone()
	newteam.Parent = script.Parent
	newteam.Visible=true
	newteam.TeamName.Text = v.Name
end
1 Like

Did you name each team “Westerosi”, “Vhegaria”, and “Bloodline of Vhegaria”?

1 Like

yeah just double checked for spelling errors as well

1 Like

Can you show your explorer? I just want to make sure.

1 Like

Ok,the thing is u need to do this

If v:IsA(“your team name”) then

End

1 Like


How would I insert this exactly? Or where

1 Like

Did you make it a LocalScript?

1 Like

Bascially,inside your loop that you have created

1 Like

Just changed to a local script now, it’s popping up only Vhegaria, not the other teams

1 Like

And I’m unable to select the teams