Script not seeing children (Very Confused)

Hello, I’m currently having this problem where I’m so confused it just could be a studio bug. Here’s an image of the assets inside the folder:
image
Script:

for i, npc in pairs(NPC_Folder:GetChildren()) do

	if npc:IsA("Script") then return end
	
	print(npc.Name, i)
   end
end

Output:

 18:40:54.184  Shop Dealer 1  -  Server - DamageIndicatorScript:9

As you can see it ignores everything else. Any ideas why this is? I tried restarting roblox studio, restarting my computer, etc. No help. Please help I’m very confused.

Thank you.

1 Like

Try this.

for i, npc in pairs(NPC_Folder:GetChildren()) do
	if not npc:IsA("Script") then
	    print(npc.Name, i)
    end
end
2 Likes

perhaps:

for i, npc in pairs(NPC_Folder:GetChildren()) do
	if npc:IsA("Model") then
	    print(npc.Name, i)
    end
end
1 Like

typing return breaks the loop. If you want to keep the loop going and skip over the script you need to use continue instead.

Like this:

for i, npc in pairs(NPC_Folder:GetChildren()) do

	if npc:IsA("Script") then continue end
	
	print(npc.Name, i)
   end
end
4 Likes