Error defining a GUI from a different GUI

Greetings!

I’ve been working on a new intro UI recently and i want that, whenever a player joins, they can see only the intro UI.
For this reason there are two GUI’s named IntroGUI and NewMenu.

I tried to define NewMenu from a local script inside IntroGui so i can make it not enabled but i get the error “NewMenu is not a valid member of PlayerGui”. I don’t know how to fix it.

Placement : image

Script (only the error part) :

local NewMenu = script.Parent.Parent.NewMenu

player.CharacterAdded:Connect(function()
   NewMenu.Enabled = false
end)

Note : I took from the original script only the important parts that are needed in this topic.

Thank you for helping!

2 Likes

Try use Visible on all of the frames instead of using the whole UI.Enabled.

Here’s script

game.Players.PlayerAdded:Connect(function(player) --Runs when player joins
player.CharacterAdded:Connect(function(character) --Runs when player respawn
  player.PlayerGui:WaitForChild("NewMenu").Enabled = false -- You need to get player gui instead of starter gui
end)
end)

Just use WaitForChild:

local NewMenu = script.Parent.Parent:WaitForChild("NewMenu")

This should fix the issue.

1 Like