Roblox Developer Logo Get Started Learn Roblox API Reference Community


< Scripting | Data Types

A userdata is the type Lua uses for data structures in the underlying C program. There aren't native Lua functions for handling those types, so they must be handled via metatables. All Roblox objects and events are userdatas.

Using userdatas

You can create a new userdata with an empty metatable by passing true to the undocumented newproxy function. This userdata cannot be used for anything other than invoking functions via its metatable.

local ud = newproxy(true) -- new userdata with an empty metatable
getmetatable(ud).__index = {Foo = "Bar"} -- index metamethod
print(type(ud), ud.Foo)
userdata: 0x631fc8	Bar