I'm trying to make a function that finds out if the argument that's passed is a physical object or not.
Here's the code:
local function IsObject(v) return type(v) == "userdata" end print(IsObject(workspace.Baseplate)) -- > true
So far so good.
Here's the problem
All physical objects are userdata values. All userdata values, are NOT
physical objects. Userdata is ROBLOX Lua specific data structure. That includes data such as: BrickColor, CFrame, Vector3, and more.
Now let's try this again:
local function IsObject(v) return type(v) == "userdata" end print(IsObject(CFrame.new())) -- > true print(IsObject(Vector3.new())) -- > true print(IsObject(BrickColor3.new())) -- > true
See the problem here? Is there a way I can make a function return true ONLY if the argument passed is a physical object?