API:Class/Instance/IsA

IsA

Function of Object Icon.pngInstance
bool IsA (
    string className
)
Parameters:
  1. className

Returns: bool
Description: Returns true if the object is an instance of the given class, or if the object's class inherits from the given class.

Example

Usage of IsA to test class inheritance:

print(Workspace:IsA("Instance" )) --> true
print(Workspace:IsA("Workspace")) --> true
print(game:IsA("Workspace")) --> false
print(game:IsA("DataModel")) --> true

A script that will change the BrickColor of any part parented directly to the Workspace.

for i,child in pairs(game.Workspace:GetChildren()) do
	if child:IsA("BasePart") then
		child.BrickColor = BrickColor.new("Bright red")
	end
end