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.

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

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:

1local part = pathhere or script.Parent
2if part:IsA("TextButton") then
3    part.Text = "eueueueueue"
4end
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

1function TestForPart(Instance)
2    if Instance:IsA("BasePart") then --basepart includes any type of part
3        return "Is A Part"
4    else
5        return "Not a Part"
6    end
7end
8 
9print(TestForPart(workspace.Baseplate))

Answer this question