Script is not recognizing a parent's children

I am trying to get a Text button to call a function but the script doesn’t recognize it nor auto fills it even though it is parented to the Shop Frame.

The script doing this error is “GUIScript”
image

image

image

I have tried using :FindFirstChild() and :WaitForChild(), along with restarting studio but nothing works.

-Some more info:
The game is in Team create.
Multiple functions are called when specified buttons are pressed in the GUIScript.
Every other function in the script can recognize the children.
The script.Parent.Shop only shows properties in the autofill scroll menu.
Even when typing the whole name of the button it gives an error because it cannot find the child.

image

  • Make sure that the TextButton is indeed a child of the “Shop Frame.”
  • Check the capitalization and spelling of the child name. Lua is case-sensitive, so make sure the child’s name in your script matches exactly with the child’s name in the hierarchy.
  • Ensure that the “Shop Frame” is visible and not hidden or disabled at runtime.
  • In Team Create, it’s possible that the script is executing before the TextButton is created or parented. Ensure that your script execution order is appropriate. You can use :WaitForChild() to make sure the TextButton is found before the script proceeds.
local shopFrame = script.Parent:WaitForChild("ShopFrame")
local textButton = shopFrame:WaitForChild("YourTextButtonName")
  • In rare cases, especially in complex Team Create projects, the GUI might have gotten into an inconsistent state. Try recreating the TextButton and ensure it is properly parented to the “Shop Frame.”

  • Verify that your script is in the same hierarchy level as the “Shop Frame” so that it can properly access its children.

  • Check for any script errors that might be causing the script to stop execution before reaching the part where it’s supposed to work with the TextButton. Check the output for any error messages.

Now I really can’t think of any others, these are the only issues I have faced when a script is not recognizing a parents child.

3 Likes
local BuyJ = script.Parent.Parent:FindFirstDescendant("BuyJ")

if BuyJ then
   -- condition
end
1 Like

For some reason, naming the Frame “Shop” makes the script not recognize it’s children… Roblox studio is weird

Ok here’s something that’s funny and dumb from me; THERE WERE 2 FRAMES NAMED SHOP :sob: :sob: :sob:

If my solution was correct, please mark it solution then. Thanks!

1 Like

Oh well. At least you figured it out!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.