Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

2 comments

0

It works, and I did some more reading last night.

0

glad to hear. the teams table isnt used in your code atm,but tables are REALLY useful

	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.

3 comments

0

game.Players.Player will error

0

good reply though

0

Thanks for giving my hopes up or something like that, @royaltoe

This discussion is preserved as it was. New answers, comments, and votes are closed.