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

215 views Asked by At

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.

2

There are 2 answers

7
Cmb On

Just use this code

ConfirmGUI.TextButton.Visible = false
ConfirmGUI.TextButton2.Visible = false
ConfirmGUI.TextLabel.Visible = false
ConfirmGUI.TextTitle.Visible = false
0
killerderp7 On

Try using: script.Parent...Parent:WaitForChild('ConfirmGUI').ScreenGUI, or flip ScreenGUI and ConfurmGUI