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

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

Asked by 4 years ago

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

0
Are You parenting the Same ScreenGUI where the button is placed? S0NIC_Dev 61 — 4y
0
No, they are different, the button is in a different screengui which has a different name. airsoft561 -3 — 4y
0
try placing the gui in StarterGUI DangerousKillerTimur 54 — 4y

2 answers

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

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

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)

Answer this question