Attempt to index nil with 'Visible'

Title says it all. I tried to search a solution in another topics, but the only one that has a script like mine has no responses :slight_smile:

local Folder = script.Parent
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("BobOS"):WaitForChild("Graphics")

--//StartMenu
Folder.StartMenu.Changed:Connect(function()
if Folder.StartMenu.Value == true then
PlayerGui:FindFirstChild(Folder.StartMenu.Name).Visible = true
else
PlayerGui:FindFirstChild(Folder.StartMenu.Name).Visible = false
end
end)

Whatever you’re trying to find is nil.

This is nil.
Edit this


Folder.StartMenu.Changed:Connect(function()
   local startMenu = PlayerGui:FindFirstChild(Folder.StartMenu.Name)
   if not startMenu then return warn("Invalid object, object not found)"
   if Folder.StartMenu.Value == true then
      startMenu .Visible = true
   else
      startMenu .Visible = false
   end
end)

How is that possible, if the function is only fired when everything else is already loaded?

if

and

then the parent of the script is the playerGui? That means that folder and PlayerGui are the same thing? pretty sure it’s wrong

Because apparently something with the StartMenu’s name is not parented under PlayerGui.

Both are in PlayerGui, but in separated folders. One is in a folder called “Graphics” and the other one is scripted.Parent

Can you send a screenshot of what PlayerGui looks like in explorer, I think the issue is that you’re checking the child of the PlayerGui, instead of the correct folder.

Because you just stated that it’s parented to the folder, not to the PlayerGui, so you have to instead :FindFirstChild() from the folder.

Make sure the thing you’re trying to find’s name is “StartMenu”

image

I think the error is because “StartMenu” is not directly parented to “Graphics”
But when I try using :FindFirstDescendent() I receive FindFirstDescendant is not enabled

StartMenu’s name is “StartMenu”, you’re looking for a child called “StartMenu” directly under PlayerGui.

The other thing called StartMenu is in Opened not Graphics

Why aren’t you just typing PlayerGui.StartMenu.Visible = true/false? it will have the exact same behavior.

Edit: Just read one of your replies, to make FindFirstChild recursive you have to pass true as the second parameter(so it acts as find first descendant):

Folder.StartMenu.Changed:Connect(function()
	local StartMenu = PlayerGui:FindFirstChild("StartMenu", true)
	StartMenu.Visible = Folder.StartMenu.Value
end)
3 Likes

Yeah I thought about that too, but first I thought if I specified the folder that I want to locate the Child I would avoid that. And also when I change the name it still happens for some reason:

PlayerGui:FindFirstChild("StartMenuPLSGOD").Visible = true

I thinked about that too, then I changed the name and the script, but it still happens…
image
PlayerGui:FindFirstChild("StartMenuPLSGOD").Visible = true

The issue is that the folder is called “Opened” not “StartMenu”

Also I am getting a bit confused, can you send another screenshot with the button you’re pressing marked and whatever frame you want to activate also marked.

Pretty confusing naming here:
local PlayerGUI = blah…graphics folder.
The you try to find the first child called Folder in the graphics folder (aka playergui) for the startmenu. Logically then the startmenu must be a sibling of the script?
But as your screen shot shows it isn’t.

Please check the edited reply above.

1 Like

Now I don’t get it. What’s wrong with what exactly? I mean, the folder where it looks to the ImageGui is the graphics folder

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

and the opened folder is only called to check if the boolean value is equal to true or false, which works perfectly for now.

Folder.StartMenu.Changed:Connect(function()
if Folder.StartMenu.Value == true then

Can you send a screenshot please it’d help greatly in this mystery of sherlock holmes.

Does this help?

local Folder = script.Parent
local Graphics = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("BobOS"):WaitForChild("Graphics")

--//StartMenu
Folder.StartMenu.Changed:Connect(function()
    if Folder.StartMenu.Value == true then
        Graphics.Desktop.Background.StartMenu.Visible = true
    else
        Graphics.Desktop.Background.StartMenu.Visible = false
    end
end)
1 Like