Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How do you make a GUI that is exclusive for a team??

Asked by 4 years ago
Edited 4 years ago

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?

0
/ Vortex_Vasne 89 — 4y
0
@Vortex_Vasne I love how you sent him to a website clearly explaining why you downvoted :) I would have done the same thing. I hate it when a person asks for free scripts, especially illegitamitely without any descriptions, motives, or reasoning. New developers and users cannot have a one liner by any means neccessary RBLXNogin 187 — 4y
0
Ight Im going to add the script that didn't work. I don't have much to add that works but ill try. dogethefrog 12 — 4y
0
Better. Vortex_Vasne 89 — 4y

3 answers

Log in to vote
1
Answered by 4 years ago

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)
0
Hey! Swatdude22 0 — 2y
Ad
Log in to vote
0
Answered by
IcyEvil 260 Moderation Voter
4 years ago

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
0
Workspace.Script:2: attempt to index local 'Players' (a nil value) dogethefrog 12 — 4y
0
Also It does not use team color it uses brick color. dogethefrog 12 — 4y
0
Oh I know what I did wrong, my mistake IcyEvil 260 — 4y
0
LocalPlayer doesn't have a 'Teams' property, just TeamColor. Oopsie, as well as it using brickcolor IcyEvil 260 — 4y
Log in to vote
0
Answered by 4 years ago

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.

Answer this question