Infinite yield possible on 'Workspace.MainMap:WaitForChild("Waypoints")' (x2)

I am completely sure the folder lies in where it should be, and I still get the error. Any ideas?

image

local Map = workspace:WaitForChild("MainMap")

local Waypoints = Map:WaitForChild("Waypoints")
repeat task.wait() until Map:FindFirstChild("Waypoints")
Waypoints = Map:FindFirstChild("Waypoints")
1 Like

First of all WaitForChild calls the MainMap’s children as well as itself so you don’t need to WaitForChilds further on. Also, where is this script? In most cases you will not need to WaitForChild for stuff in the workspace. I recommend just tweaking it and trying it out.

1 Like
  • The script is inside a NPC Model
  • And what should I use instead of WaitForChilds?

Hmmm. You could try GetDescendants on the folder to return everything inside it. Or GetChildren

well, im trying to simply just do:

local Waypoints = workspace.MainMap.Waypoints

Can you try this because use wait for child and find first child it’s not a fast way.
Try this solution:

repeat task.wait() until workspace:FindFirstChild("MainMap") and workspace:FindFirstChild("Waypoints")

And put your script below…

1 Like