Accessory Inserted with InsertService:LoadAsset(Id) has a Handle of type "userdata"

When I insert an asset with InsertService:LoadAsset(Id), I get a model with an accesory in it. When I try to get the handle with this code:

local accessory = InsertService:LoadAsset(Id):FindFirstChildOfClass("Accessory")
local part = accessory:FindFirstChildOfClass("BasePart")

print(part) --prints nil

This happens with all the asset Ids I use. When I print what type of object the handle is, it prints “userdata”

local accessory = InsertService:LoadAsset(Id):FindFirstChildOfClass("Accessory")
local part = accessory.Handle
print(type(part)) --prints "userdata"

Place for the glitch. Scripts are in serverscriptservice.

RobloxAccessoryTypeGlitchPlace.rbxl (76.3 KB)

Expected behavior

I expected the code to return a base part, or type of the handle to be base part.

hey! this is expected behavior. if you’re expecting type Instance, you should use typeof(obj) instead of type(obj). typeof allows an implementer (in this case Roblox) to specify types on userdata, whereas type does not.

1 Like