IsA (Function): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>LPGhatguy
Fixing wording/spaces
>LPGhatguy
No edit summary
Line 4: Line 4:
name                  = IsA
name                  = IsA
|arguments            = [[String]] class name
|arguments            = [[String]] class name
|returns              = [[Boolean]]
|returns              = [[Boolean]] Is class or subclass
|description          = Returns whether the instance is a class or subclass of the provided class name.
|description          = Returns whether the instance is a class or subclass of the provided class name.
|object              = Global
|object              = Global

Revision as of 21:12, 27 December 2010

IsA( String class name )
Returns Boolean Is class or subclass
Description: Returns whether the instance is a class or subclass of the provided class name.


IsA is useful for figuring out if an object is a specific type of object. For example, if you do Part:IsA("Part") it will return "true". Also, you can use structural classes, or classes that cannot be created through Instance.new(string classname). For example, you can do Part:IsA("BasePart").

Example
This can be used to find an object related to a part in a list of objects.
children = script.Parent:GetChildren()

for i=1, #children do
    if children[i]:IsA("BasePart") then
        print(children[i].Name .. " is a Part object.")
    end
end