Is it possible to get an instance's reference id?

I want to be able to get an instance’s unique reference id (the kind that is printed when setting an instance as a dictionary key) in order to add a string at the end of it for indexing a table (experimenting with ECS).

I don’t know how to find an object’s reference id outside of printing it from a table, then using log service to read the output which is very gimmicky and inefficient.

Reference IDs are basically unique identifiers each instance has on roblox. Since ECS / DOD is supposed to be a more memory efficient version of OOP, using a property or an attribute seems to defeat the point in most cases, hense randomly generating external IDs is most likely not going to work.

1 Like

That appears to be the only way to fetch an instance’s memory address.

local game = game
local logService = game:GetService("LogService")
local connection

local function onMessageOut(message)
	connection:Disconnect()
	for memAddr in string.gmatch(message, "%b()") do
		print(memAddr)
	end
	connection = logService.MessageOut:Connect(onMessageOut)
end
connection = logService.MessageOut:Connect(onMessageOut)

local t = {}
for _ = 1, 5 do
	t[Instance.new("Part")] = true
end
print(t)

image

5 Likes

There really needs to be a better way of reading object references…

2 Likes