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

How do I have a button make a frame that is in a separate ScreenGui visible?

I want to make a button that when you click it it makes a Gui that is in a separate ScreenGui visible. I tried doing using script.parent, but it said that the frame I wanted wasn't a valid member of PlayerGui. I tried doing Game.StarterGui, but that didn't work either. It didn't even give me an error.

Here is my attempts

--Script 1

local frame = game.StarterGui.SignUp.SignUpMainFrame
local open = false

script.Parent.MouseButton1Click:Connect(function()
	if frame.Visible == false then
		frame.Visible = true
	end
end)

--Script 2

local frame = script.Parent.Parent.Parent.Parent.Parent.Parent.SignUp.SignUpMainFrame
local open = false

script.Parent.MouseButton1Click:Connect(function()
	if frame.Visible == false then
		frame.Visible = true
	end
end)

3 answers

I'm not sure what you're trying to achieve.

local player = game.Players.LocalPlayer  -- get the local player
local playerGui = player:WaitForChild("PlayerGui") -- wait for players PlayerGui to load in
local otherFrame = playerGui:WaitForChild("ScreenGui2").Frame -- destination to other screengui's frame

script.Parent.MouseButton1Click:Connect(function()
	otherFrame.Visible = not otherFrame.Visible -- When clicked, it acts like a toggle. If you frame is not visible, clicking it makes it visible and vice verca.
end)

Please send a screenshot of your GUI section in the explorer so I know what code to write.

Try it

local frame = game.Players.LocalPlayer.PlayerGui:WaitForChild("SignUp").SignUpMainFrame
local open = false

script.Parent.MouseButton1Click:Connect(function()
	print(frame.Visible)
	if frame.Visible == false then
		frame.Visible = true
	end
end)

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