Instance:IsA() broken?

i have an ipairs for loop which iterates through game:GetDescendants() and checks if the descendant is a BasePart, somehow the roblox terrain object is being recognized as a BasePart

while task.wait(1) do

	for _,Descendant in ipairs(game:GetDescendants()) do
	
		if Descendant:IsA("BasePart") then
			
			if Descendant.ClassName == "Terrain" then
				
				print("How Is This Classified As A BasePart???")
				
			end
		end
	end
end

how

Instead do

if Descendant:IsA("BasePart") and not Descendant:IsA("Terrain") then
2 Likes

This Documentation states that Terrains are considered BaseParts also.

BasePart is an abstract base class for in-world objects that render and are physically simulated while in the Workspace. There are several implementations of BasePart, the most common being Part and MeshPart. Others include WedgePart, SpawnLocation, and the singleton Terrain object. Generally, when documentation refers to a “part,” most BasePart implementations will work and not just Part.

i realize i can do this, but why cant the function just work as intended? instead of having to do hacky workarounds

No, Terrain is a BasePart. Unfortunately I can’t find any class tree on the wiki, but you can usually see what superclasses a class has based on it’s “inherited from”

so its intended? sorry @KJry_s i guess your solution is actually the best one then.

Because they copy over properties which the BasePart has.

wouldnt setting properties like cframe and size error though? considering terrain doesnt have those properties

Apparently not LOL

https://create.roblox.com/docs/reference/engine/classes/Terrain
(Go under inherited from BasePart)

image

Try it and see. I’d guess not, but it probably won’t actually do anything either.

I’d guess it was just the simplest way of making it work with other systems that expect to work with BaseParts, like raycasts, physics constraints and probably other things.

I think that the BasePart class is made for everything renderable and physical in the game.

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