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

(This is not a group like gui its uses the teams system)How do I fix my team only Gui?

Asked by 5 years ago
Edited 5 years ago

So I have a Gui that when clicked it should only open for a team called Adult All the Main assets were put in different names, but what I'm saying is that there are 5 errors after each other and I have no idea of what to do or what went wrong nothing is said in the output, or the developer. So I'm really really confused about what went wrong.

---Script---

local frame = script.Parent.Parent.Frame2
local open = false
local others = Teams.Kid
local others = Teams.Teenager
local others = Teams.Pet
local Person = Playes.Player
local Main = Teams.Adult


script.Parent.MouseButton1Click:Connect(function()
    if Person.Team == Main then
        frame.Visible = true
    elseif
        Person.Player.Team == others then
            frame.Visible = false
    end
end)

---Errors---

local frame = script.Parent.Parent.Frame2
local open = false
local others = Teams.Kid ---Error
local others = Teams.Teenager ---Error
local others = Teams.Pet ---Error
local Person = Playes.Player ---Error
local Main = Teams.Adult ---Error


script.Parent.MouseButton1Click:Connect(function()
    if Person.Team == Main then
        frame.Visible = true
    elseif
        Person.Player.Team == others then
            frame.Visible = false
    end
end)

---Proof of Error--- https://gyazo.com/adea1a53ca8b6476826ec67b997fca6e

2 answers

Log in to vote
2
Answered by
royaltoe 5144 Moderation Voter Community Moderator
5 years ago

To avoid the error, say game.Teams instead of Teams. Also, to reference the player, say "game.Players.LocalPlayer"

I explained tables to you in the chat but if you need anymore explanation let me know

local frame = script.Parent.Parent.Frame2
local isOpen = false 

--table of all the teams...
--equivalent to saying: 
--teams = { game.Teams.Adult, game.Teams.Kid, game.Teams.Teenager, game.Teams.Pet }
teams = game.Teams:GetChildren()

--gets a reference to the player
player = game.Players.LocalPlayer 

local defaultTeam = game.Teams.Adult


script.Parent.MouseButton1Click:Connect(function()
    if player.Team == defaultTeam then
        frame.Visible = true
    elseif player.Team == others then
            frame.Visible = false
    end
end)
0
It works, and I did some more reading last night. vincentthecat1 199 — 5y
0
glad to hear. the teams table isnt used in your code atm,but tables are REALLY useful royaltoe 5144 — 5y
Ad
Log in to vote
1
Answered by 5 years ago
    local frame = script.Parent.Parent.Frame2
    local open = false
    local others = game.Teams.Kid
    local others = game.Teams.Teenager
    local others = game.Teams.Pet 
    local Person = game.Players.Player
    local Main = game.Teams.Adult 


    script.Parent.MouseButton1Click:Connect(function()
        if Person.Team == Main then
            frame.Visible = true
        elseif
            Person.Player.Team == others then
                frame.Visible = false
        end
    end)

Try this. It said there was no errors in mine. I think I might have known the problem. You forgot to put game before ".Teams.", instead, you did "local others = Teams.Pet". Let me know for any issues.

0
game.Players.Player will error royaltoe 5144 — 5y
0
good reply though royaltoe 5144 — 5y
0
Thanks for giving my hopes up or something like that, @royaltoe C0nn0r_DevCT 42 — 5y

Answer this question