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

Doesn't find the gui even tho it's there?

I made an GUI opening button:

local frame = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame

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

but I get this error:

ScreenGui is not a valid member of PlayerGui

The name of the GUI's frame I want to make invisible is:

ScreenGui

3 comments

0

Are You parenting the Same ScreenGUI where the button is placed?

0

No, they are different, the button is in a different screengui which has a different name.

0

try placing the gui in StarterGUI

2 answers

✓ Accepted answer

You can use the Operation such as :WaitForChild() and :FindFirstChild()

local ScreenGui = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui")

local frame = ScreenGui:FindFirstChild("Frame")



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

maybe use :findFirstChild() or :WaitForChild() like this

local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local ScreenGui = playerGui:WaitForChild("ScreenGui")
local frame = ScreenGui:WaitForChild("Frame")

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

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