IsA (Function): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>LPGhatguy
Fixing wording/spaces
>Camoy
Redirecting to IsA (Method)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{|
#REDIRECT [[IsA_(Method)]]
|<onlyinclude>
{{Function|
name                  = IsA
|arguments            = [[String]] class name
|returns              = [[Boolean]]
|description          = Returns whether the instance is a class or subclass of the provided class name.
|object              = Global
|}}</onlyinclude>
|}
 
 
IsA is useful for figuring out if an object is a specific type of object. For example, if you do <code>Part:IsA("Part")</code> it will return "true".  Also, you can use structural classes, or classes that cannot be created through <code>Instance.new(string classname)</code>.  For example, you can do <code>Part:IsA("BasePart")</code>.
 
{{Example|This can be used to find an object related to a part in a list of objects.
 
<pre>
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
</pre>
}}

Latest revision as of 21:13, 27 December 2010

Redirect to: