Help with some weird errors

Hello developers!
I am currently working on my game UI and recently got some weird errors:


image

Looks like usual simple errors that you always have when scripting something, but these are different. They doesn’t stop the script from working and doesn’t seem to make sense.

Let’s see the first error, it says that I am attempting to index nil with :WaitForChild(), so let’s go to the line 24 and check it out.

image

It is literally saying that gui.Parent is equal to nil, what I think it’s impossible since the script is a child of the “UserUi”

image

Now the second error, it says that the script could not find a child called “ItemButton”, but if you check the code and explorer you won’t find anything wrong with it:
image
image

As I said, the scripts works fine, but for some reason it always prints these errors when I play and it is very annoying. I would like to know if you guys ever had problems like this one and if is there any solution for it.

Thanks for the attention!

3 Likes

Sorry but I only know one of those errors the yellow one won’t stop the script, it’s saying that it might wait infinitely for the child (item button) because it can’t find it immediately and it should be able to. Tell me if you need more explanation cause I think mine might have grammar errors… @Br0kenT04st I wrote too quick :slight_smile:

2 Likes

Hey, thanks for your answer. Yes, I know what the error is saying but it doesn’t make any sense since the script is right:

1 Like

Please give me further details on what you are trying to establish.

I am just trying to get the “ItemButton” that is a child of the local script.

No like what feature are you trying to make? A class selector?

For line 24 try printing script.Parent and on line 20 does it find ItemButton even if it was late?

image
I added a print and it prints “UserUi”
image

about the line 20, I didn’t understand, what do you mean with “Find Item Button even if it was late”?

it was actually script.Parent:WaitForChild("ItemButton") and not script:WaitForChild("ItemButton")

Nope, the ItemButton is inside of the LocalScript:
image

1 Like

You wrong on locating if your make
local gui= script.Parent
local button gui:WaitForChild(“Button”)

But if your make like that 100% wrong because your button is located inside localscript so i suggest you put outside the button or you can make new variable for it like this
local Script = script
local button = Script:WaitForChild(“Button”) — so it will be working or you can make it FindFirstChild, if button then – code end, Hope ita helpful :slight_smile:

Use new variable because your button is inside the localscript so if you make the variable script.Parent and WaitForChild button it will not found or error/stuck end so you need to move your button to outside/inside gui not localscript or you can make a new variable for it like local script = script local button= script:WaitForChild(“button”) or you can make it FindFirstChild so if button then - - your code end

1 Like

So, I made what you said and put the button inside the script parent:
image
I also changed the code:
image

Now it says that script.Parent = nil, like the other error… :frowning:

This looks like a studio bug…

Try use script.Parent.Parent for it so it will located to menuframe and on menuframe will find objects inside the frame

If I do that the script will still print an error because there is no “ItemButton” inside script.Parent.Parent (ShopGui)
image

I am not a proffesional scripter but I would have said maybe use FindFirstChild

1 Like

Locate ur localscript outside frame is confusing me my game is using like that 1 screengui using 1 localscript and isnot located inside frame because is confusing

Still gets the same error

Do this to know what is inside frame
for i,v in pairs(script.Parent:GetChildren()) do
print(v)
end

2 Likes

Did it, and it finds the ItemButton
image

1 Like