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

What is wrong with this script? (GUI's)

Hello, I am trying to make a script where if you click a button another it checks if the player is either iiTiago or AyeeJordy and when it is the correct player it will open another frame and close the current frame which is open BTW the other frame that's meant to open is within the StarterGui. No errors showed up

-- iiTiago 2K16

local Mainbtn = script.Parent
local AdmPan = game.StarterGui.City_Gui.AdminPanel
local Mainf = Mainbtn.parent.parent.Parent

function open(plr)
	if plr.Name == "iiTiago"or"AyeeJordy"or"Player1" then
			AdmPan.Visible = true
			Mainf.Visible = false
		end


script.Parent.MouseButton1Click:connect(open)


-- iiTiago 2K16

1 answer

✓ Accepted answer

The MouseButton1Click event does not pass on the player as one of its arguments. Instead declare the variable using game.Players.LocalPlayer:

-- iiTiago 2K16

local Mainbtn = script.Parent
local AdmPan = Player.PlayerGui.City_Gui.AdminPanel --You want the PlayerGui rather than StarterGui
local Mainf = Mainbtn.Parent.Parent.Parent --"Parent", not "parent"

local Player = game.Players.LocalPlayer --<<<<<

function open()
    if (Player.Name == "iiTiago") or (Player.Name == "AyeeJordy") or (Player.Name == "Player1") then
            AdmPan.Visible = true
            Mainf.Visible = false
        end
end  --You were also missing this end :p


script.Parent.MouseButton1Click:connect(open)


-- iiTiago 2K16

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