I have a folder named “Patrol” with 5 parts in it. Whenever I try to get the number of children, it returns 0.
local patrolPoints = game.Workspace:WaitForChild("CurrentMap"):WaitForChild("Patrol")
local waypoints = patrolPoints:GetChildren()
if waypoints then
warn(#waypoints)
end
local patrolPoints = game.Workspace:WaitForChild("CurrentMap"):WaitForChild("Patrol")
local waypoints = patrolPoints:GetChildren()
if waypoints then
warn(#patrolPoints:GetChildren())
end
Hard to say without looking at their explorer. It’s possible that none of the children are being loaded in at the time of using :GetChildren. It’s also possible that the first child found and placed in the table is being read as nil. If that is the case, then trying to find the table size using #patrolPoints:GetChildren() would yield 0.
If you’re looking through the folder intended, it sounds like you ran getchildren before any of the children even existed, you can debug this easily like so,
local patrolPoints = game.Workspace:WaitForChild("CurrentMap"):WaitForChild("Patrol")
local waypoints = patrolPoints:GetChildren()
if waypoints then
warn(#waypoints) -- This is your current first attempt
warn(patrolPoints:GetFullName()) -- Does this print the folder you want to look through?
for i = 1,10 do
wait(.5)
warn(i,#patrolPoints:GetChildren()) -- check if any of this prints the right amount
end
end
If any of those 10 loop prints 5, then you know it’s the issue of them not loading in yet