How to fix this GUI button?

So basically I have this camera manipulation script where when you click the button to show it checks if the main frame is invisible, if it is then it makes it visible, and the close button does the opposite, but both those buttons don’t work for some reason, they do nothing & show nothing in output (the other buttons for camera manipulation work fine though)

This is the GUI:
RobloxStudioBeta_0MOuip7TJP

MainFrame Button Script (has the ‘Close’ button):

local gui = game.StarterGui.Cameras
local frame = gui.ShowButton
local button = script.Parent

button.MouseButton1Click:Connect(function()

	if gui.MainFrame.Visible == true then
		gui.MainFrame.Visible = false
		frame.Visible = true
	end

end)

ShowButton Script:

local gui = game.StarterGui.Cameras
local frame = gui.ShowButton
local button = script.Parent

button.MouseButton1Click:Connect(function()
	
	if gui.MainFrame.Visible == false then
		gui.MainFrame.Visible = true
		frame.Visible = false
	end
	
end)

You’re using StarterGui when you need to be using PlayerGui. I’m assuming this is a client sided script, so you just need to do something like game.Players.LocalPlayer.PlayerGui.Cameras.

1 Like

Seems to be working, tysm <3!!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.