When Clicking On ClickDetector, GUI won't show up?

I’m currently redoing a system for someone which involves a ClickDetector and a Gui. Well I’ve been having trouble with this and it seems to not be working. The script type is the normal script type, would a LocalScript need to be required by any chance?

Code:

local button = script.Parent
local clickdetector = button.ClickDetector


function onMouseClick()
	game.StarterGui.ButtonGui.Frame.Visible = true
end
	clickdetector.MouseClick:connect(onMouseClick)

You can’t reach the StarterGui using a script. Try using player.PlayerGui or a remote event

1 Like

How exactly would you make it so when you click the button it will fire an event to make the gui visible?

You can’t use starter gui when editing ui. Starter gui is where all of the ui is copied and is placed inside of the player’s player gui. Try accessing the player gui instead of starter gui.

HOW TO MAKE A OPEN/CLOSE BUTTON GUI! || Roblox Studio 2019 - YouTube

As others have said, the Starter Gui cannot be accessed. You need to pick up the player parameter in the clicked event, then edit the UI from there.

function onMouseClick(player)
	-- The player that clicked is picked up
end

Once that is done, you need to find the player GUI.

function onMouseClick(player)
      local playerUI = player:FindFirstChild("PlayerGui")
end

Then when that is done, you can set the frames visible property to true,

function onMouseClick(player)
	local playerUI = player:FindFirstChild("PlayerGui")

	playerUI.ButtonGui.Frame.Visible = true
end

clickdetector.MouseClick:connect(onMouseClick)
2 Likes