GUI doesn't appear when TextButton is clicked

Hey,
So what I’m trying to do is enable the Gamepass gui once the textbutton is clicked. The thing is - it says that the gui is enabled even though it’s invisible. Am I doing something wrong?

local gui = game.StarterGui.Gamepass
local button = script.Parent

local function onClick()
	if gui.Enabled == true then
		gui.Enabled = false
	else
		gui.Enabled = true

	end
end

button.MouseButton1Click:connect(onClick)

image

So, you are not changing the Player’s GUI, you are changing the Starter GUI which won’t replicate instantly to the screen.

Instead do:

local gui = game.Players.LocalPlayer.PlayerGui.Gamepass
1 Like

Hey, so your solution worked for a short amount of time, then it just said this:
Gamepass is not a valid member of PlayerGui "Players.[NAME].PlayerGui"
What’s happening??

Hello! That error means that there’s no GUI named “Gamepass”. Make sure you didn’t deleted it.

Send me the script so I can take a look at it.

1 Like

Hi again,
I just fixed it and it was a silly issue. I just needed to do
local gui = game.Players.Localplayer.PlayerGui:WaitForChild("Gamepass")

Thanks for the help!

1 Like