Why doesn't my button work?

Hello everyone,

While making a model that has a surface GUI with a text button, the scripts don’t work

here are the scripts and a photo of the explorer

https://gyazo.com/ffc9d1c33eae21d90866c5e1d2b4777a

https://gyazo.com/332603e1c19ad2e2f29fed6b09140bdd

script to open-

local frame = game.StarterGui.ScreenGui1.Frame
local fixButton = script.Parent

fixButton.MouseButton1Click:Connect(function()
 frame.Visible = true
end)

2nd script, to close

local frame = game.StarterGui.ScreenGui1.Frame
local exitButton = game.StarterGui.ScreenGui1.Frame.Exit

exitButton.MouseButton1Click:Connect(function()
 frame.Visible = false
end)

If you need more information, send me in the replies!

1 Like

Screen Gui:

  • You are using StarterGui not PlayerGui. Use Relative paths instead.

Surface Gui:

  • You must have the Surface gui parented to PlayerGui so it knows what player is interacting with it

PlayerGui, i’m sorry, but where is that located?

I said use a relative path. PlayerGui is located inside a player (each player sees different things). When a player joins. everything from startgui is cloned into PlayerGui

there is only one player in the game tho

I said use a relative path. as i said everything from starterGui gets cloned into PlayerGui and changing it won’t change it in the PlayerGui

The path is this:

local player = game.Players.LocalPlayer
player.PlayerGui.ScreenGui1.Frame

yes, I remembered that, now I hope it works