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
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
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
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