I am trying to make a GUI that is exclusive for a team. Like a GUI that become visible if a player is on a certain team. Here what I thought to do:
local Players = game:GetService("Players") local Teams = game:GetService("Teams") if Players.LocalPlayer.Teams == BrickColor.new("New Yeller")then game.StarterGui.Buttons.Host.Visible = true else game.StarterGui.Buttons.Host.Visible = false end
No result in input but nothing happened. I also tried putting it in both types of script with again, no result. I also experimented with at least an error
local team = game.Teams.Host local Players = game:GetService("Players") if Players.LocalPlayer.team == game.team then --Error here (Workspace.Script:4: attempt to index field 'LocalPlayer' (a nil value))-- game.StarterGui.Buttons.Host.Visible = true else game.StarterGui.Buttons.Host.Visible = false end
What am I doing wrong?
I was able to answer my own question. I decided to use a button that would only work if you where on the host team. Here's the code that you can edit if you have the same problem
local frame = script.Parent.Parent.Parent.Host local open = false local others = game.Teams.Contestant local others = game.Teams.Judge local others = game.Teams.Audience local Person = game.Players.LocalPlayer local Main = game.Teams.Host script.Parent.MouseButton1Click:Connect(function() if Person.Team == Main then frame.Visible = true elseif Person.Team == others then frame.Visible = false script.Parent.Text = "Not right team." wait(1) script.Parent.Text = "Open Host Gui" end end)
It's been a fairly long time since i've developed on this site, but if I recall Teams don't use BrickColor, they use 'TeamColor'
Lets start with just getting 'Players' defined real quick.
local Players = game:GetService("Players").LocalPlayer
That right there removes portions of your code later on since I defined it as 'LocalPlayer' immediately.
Now lets try to figure out if the players Team is the right color.
if Players.Teams.TeamColor == (Players.Teams.TeamColor = "New Yeller") then
If i'm correct about TeamColor, then this Should work, I say should because this might be an improper way of doing what I'm trying to get across and if so I apologize, like I said it's been a very long while.
The rest of this is exactly as you were trying to do and just saying 'if the team is the right color show them this Gui, if not then don't '
game.StarterGui.Buttons.Host.Visible = true else game.StarterGui.Buttons.Host.Visible = false
Now, heres the code all together.
local Players = game:GetService("Players").LocalPlayer if Players.Teams.TeamColor == (Players.Teams.TeamColor = "New Yeller") then game.StarterGui.Buttons.Host.Visible = true else game.StarterGui.Buttons.Host.Visible = false end
You could just detect when a player joined and check their team, then clone the gui to their playergui. So if you are that team and join the game you have it, or switch teams.
team = <team color here> gui = <the location of the gui> (dont put it in startergui) game.Players.PlayerAdded:Connect(function(player) if player.Team.TeamColor == team then local clone = gui:Clone() clone.Parent = player.PlayerGui end end)
This, or something like this should work.