This script works to an extent. It checks and sees what team you are on and if you are not on the correct team you cannot view the gui (at start of game). But however if you change teams in the middle of a game it does not remove the gui. I want this script to be removed from the players screen or just not visible, but when they go back to the team that can view the gui, the gui pops back up. The Medium stone grey team can veiw the gui and the Bright red, and Bright blue team are not allowed to.
This is the script:
teams={}
Check=function()
for a,b in pairs(script.Parent:GetChildren()) do
if b.className=="BrickColorValue" then
table.insert(teams,tonumber(tonumber(#teams)+1),b.Value)
end
end
if #teams<1 then print("No Team Selection") script:Remove() return end
for c,d in ipairs(teams) do
if script.Parent.Parent.Parent.TeamColor==d then
print("OK!")
script:Remove()
return
end
end
script.Parent:Remove()
end
Check()

6 comments
thanks ill test it out!
the script has to constantly check for the player's team color, does it do that?
It checks each time a property of the Player is modified, which is an event. The :connect part fires the script whenever said event occurs.
im having trouble actually making it work, I have it pasted inside a frame with the thing at script.Parent
Does it matter that the team you start out on is Medium stone grey?
If the Frame is script.Parent, you need to change the beginning of the script to this: "local guiYouMightBeAbleToView = script.Parent"