Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

When can we use the Instance:IsA in roblox studio?

Asked by 4 years ago

When can we use the Instance:IsA in roblox studio it mainly says that we can use it to check class name but I see people use it on diffrent things is it true that we can use it for many things like on a if statement or things.

if game.Workspace.Part:IsA("Part") then
print("Part Exist!")
end

2 answers

Log in to vote
1
Answered by 4 years ago

You can use Instance:isA when an instance has special functions. I also recommend using BasePart instead of part. Example:

local part = pathhere or script.Parent
if part:IsA("TextButton") then
    part.Text = "eueueueueue"
end
Ad
Log in to vote
0
Answered by
TheePBHST 154
4 years ago

So yeah, IsA() is simply to check if it's a specific Instance.

Examples like this is to check if something is a script and you don't want to include it in a table full of parts. Also it can help find out if it fits the requirement of a function

function TestForPart(Instance)
    if Instance:IsA("BasePart") then --basepart includes any type of part
        return "Is A Part"
    else
        return "Not a Part"
    end
end

print(TestForPart(workspace.Baseplate))

Answer this question