'Why is my Luau code not hiding the GUIs that I tried to hide?

My code is for hiding some GUIs that I don't want to show. (Note that this is Luau, I can't post to DevForums because I am not a member)

This is what I want to hide: Link here

The code I used was:


local Dialog = false
local Confirm = false
local TalkTo = ""

local ConfirmGUI = script.Parent.Parent.Parent.Parent.ConfirmGUI.ScreenGui -- Avoiding waste of time writing the full directory and having to fail because it's in PlayerGUI

ConfirmGUI.TextButton.Visible = false
ConfirmGUI.TextButton2.Visible = false
ConfirmGUI.TextLabel.Visible = false
ConfirmGUI.TextTitle.Visible = false

The error I keep getting in Developer Console is:

  09:04:06.668  ConfirmGUI is not a valid member of PlayerGui "Players.metoplayllol.PlayerGui"  -  Client - LocalScript:6
  09:04:06.668  Stack Begin  -  Studio
  09:04:06.669  Script 'Players.metoplayllol.PlayerGui.DialogGUI.ScreenGui.TextLabel.LocalScript', Line 6  -  Studio - LocalScript:6
  09:04:06.669  Stack End  -  Studio

I used a title you can't see because it ruins the fun of the experience.



Solution 1:[1]

Just use this code

ConfirmGUI.TextButton.Visible = false
ConfirmGUI.TextButton2.Visible = false
ConfirmGUI.TextLabel.Visible = false
ConfirmGUI.TextTitle.Visible = false

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cmb