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

How do you check if an object is a model or a BasePart?

Asked by 5 years ago

I need to know this to determine the position of said object, if possible.

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

You can use the IsA method of instances to check if they are a part of a class. For example, if you wanted to get the CFrame of the part or model, you could do:

local function GetCFrame(Inst)
    if Inst:IsA("BasePart") then
        return Inst.CFrame
    elseif Inst:IsA("Model") then
        return Inst:GetPrimaryPartCFrame()
    end
end
0
Thank you so much! VikingCatto 15 — 5y
Ad

Answer this question