FindFirstChild returning nil

Hello! As part of my main game loop, I need to find the first child of a model in the workspace called “Hallway”. However, whenever I try to find the first child of Hallway, it returns nil, despite it being a child of the model. Wait for child causes infinite yield, and also does not work.

Here is a link to the section of my program where the issue is occuring:
https://pastebin.com/JduyqY9t

Any help is appreciated with this, since I am unsure as to why this is returning nil. Thanks!

3 Likes

Check if there are more than just one Hallway model in workspace

You shouldn’t need to use :FindFirstChild if you’re confident that the model is there. :FindFirstChild is just a safe way of checking if something with the name provided is a child of an instance.

Can you send a screenshot of your explorer?

Untitled

Are you sure that they’re there during playtest? If the parts in the model are unanchored and they all get deleted when falling too low, then I’d imagine that the model also gets deleted when there’s nothing parented to it.

1 Like

Try this

Blockquote
local hallway = game:GetService(“Workspace”):FindFirstChild(“Hallway”)

Ah good catch, forgot to anchor the spawn points. Thanks for the help!