:GetDescendants() not detecting any BaseParts

I am trying to make my Stand invisible using :GetDescendants(), however when I run a for loop within my Stand, it prints out no BaseParts.

LocalScript:
image

Inside the Stand model:
image

What it outputs:
image

Finding individual BaseParts using :WaitForChild() gives a result, its just that when I use :GetDescendants() it acts like no BaseParts exist inside the Stand, even if there are.

1 Like

Is char an NPC or Dummy, and if so, is it far away?

Try setting Workspace.StreamingEnabled to false and see if it fixes the issue. If it does, that means the issue is streaming. Generally, you want to keep StreamingEnabled on, so we’ll work together to find a better solution. If that’s not the issue, then we can keep searching for more explanations.

1 Like

char is the player’s character and the Stand is inside of the character.

1 Like

Does running
print(stand:FindFirstChildWhichIsA(“BasePart”).Name)
before the loop error?

1 Like


It indexes nil here

1 Like

Okay, so the script definitely isn’t detecting it

Playtest the game. In the test tab switch from Server to Client. Do you see the parts within the model in the explorer?

1 Like
for _, part in pairs(stand:GetDescendants()) do
	if part:IsA("BasePart") then
		print(part.Name)
	end
end
1 Like

Have you got streaming enabled? If so:
In the model, change the ModelStreamingMode to Atomic.
Then, in the script, add standFolder:WaitForChild("Head") (you don’t need to assign this to a variable) prior to the loop

Tested it, yes the parts are visible.

This worked, thank you!
But also, may I know why this works?

image

Streaming Enabled can cause things to load in at different times, and the script may run before everything is loaded (and causing the baseparts not to be found).

Changing the model to atomic means that everything in the model will load in (and load out) at the exact same time. Based on this, the `standFolder:WaitForChild(“Head”) line waits until an element (in this case “Head”) has loaded in the model, indicating the rest are loaded as well.

Then when you run the loop, the parts are all loaded and you correctly find them all

1 Like

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