IsA (Function): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Mr Doom Bringer
No edit summary
>Blocco
Added a bit more information.
Line 11: Line 11:




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".
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 a part in a list of objects.
{{Example|This can be used to find an object related to a part in a list of objects.


<pre>
<pre>
Line 19: Line 19:


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

Revision as of 22:14, 13 July 2010

IsA( String classname )
Returns Boolean
Description: Returns true if instance is that class or a subclass


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