Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.

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

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

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)
Ad
Log in to vote
0
Answered by
iiii676 23
3 years ago

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

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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)

Answer this question