Object doesn't exist when it does

Problem

I am referencing an object called ‘RANKS’ in my localscript. Apparently, it does not exist even though it does. Now I have tried :WaitForChild() but it just gives me the infinite yield error.

Script

This is part of the script that doesn’t work:

local gunsGUI = shopGUI.GUNS
local ranksGUI = shopGUI.RANKS

gunsGUI.MouseButton1Click:Connect(function()
	ranksGUI.Visible = false
	gunsGUI.Visible = true
end)

ranksGUI.MouseButton1Click:Connect(function()
	gunsGUI.Visible = false
	ranksGUI.Visible = true
end)

Image

1 Like

run the game and check if its in the player gui. the screenshot you sent is a startergui

2 Likes

What am I looking for???

1 Like

go to players > your name > player gui > mainmenu > mainmenuholder

1 Like

Yes I know that, if I am looking for the RANKS button it is there.

2 Likes

are you sure that mainframeshopgui is the only object with this name in mainmenuholder

1 Like

Yes. There are no other children called RANKS.

1 Like

no i mean are you sure if there is only 1 object named MainFrameShopGui in MainMenuHolder

1 Like

Oh, yeah there is only one of them called that.

1 Like

i remember having issues like this, but i do not remember how have i fixed them. if i think of a possible solution, i will let you know

2 Likes

are you sure there is only one MainMenuHolder? and only one MainMenu?

1 Like

Yes, there are only one of each. The error is leading to the shopGUI frame. It is nothing to do with anything else.

2 Likes

show me the shopgui variable, perhaps the issue is there

1 Like

local shopGUI = mainFrame.MainFrameShopGui

Should I add a :WaitForChild() there?

what about mainframe variable? also yeah you could try to put wait for child but i think its not gonna help

1 Like

local mainFrame = script.Parent.Parent.Parent.Parent

1 Like

i am pretty sure this should fix the issue:

local mainFrame = plr.PlayerGui.MainMenu.MainMenuHolder
1 Like


This could possible help.

1 Like

Didn’t change anything for some reason.

1 Like

could you send the entire script?

1 Like