How to get a string identifying an object?

Hello
I have several objects with the same Name and Parent - in the given case these are Character objects.
I want to get and print something which is unique for each of them - some kind of memory address or similar.

What can I use?

Thanks

4 Likes

You can generate a UUID (universally unique identifier) with HttpService.

local HttpService = game:GetService("HttpService")

local uuid = HttpService:GenerateGUID
print(uuid) --> 04AEBFEA-87FC-480F-A98B-E5E221007A90

You can read more about it here:

3 Likes

Last time I checked it was not possible to find a memory address or reference id via a script.

The right question is: why? Why not differentiate by name? Especially considering your are trying to determine character objects. At the moment I can’t think of a cogent reason not to.

2 Likes

Thanks, but I do not create these objects, so I do not want to try to generate and set fields on them.
I would like to use something existing

2 Likes

The character name is always the same. I am trying to track the moments, when the value of the player.Character is set to nil or changes during resets, dying and respawning.

2 Likes

Hmm, can you please elaborate on what exactly is expected from the script?

This sounds like a custom character. Does it have a humanoid? Couldn’t you track those changes with player.CharacterRemoving and humanoid.Died?

2 Likes

It is not a custom character.
I can find different workarounds, but my reason behind the question was to understand if there is some kind of unique field on all objects, which can be used…

2 Likes

This will return a separate debug id for every object

2 Likes

2 Likes

Yes I can see im not blind how do we know its not for a plugin or something else?

2 Likes

I see.

There definitely is a unique field (multiple actually), they’re just not accessible to scripts. Memory address, reference ID, debug ID

There is no realistic way to get those values during runtime. And there’s no sound reason to need them in normal development. Instances are differentiated by class name and name, just like functions in modules have a unique name. Besides, we can always set attributes, add values, or create some unique script references to differentiate between objects in our own way.

Fun fact: One hacky (and highly unrecommended) way to find the reference ID is reading table output in non-log mode.
local LogService = game:GetService("LogService")

local part = Instance.new("Part")

local t = {[part] = true}
print(t)

LogService.MessageOut:Connect(function(message, messageType)
	print(message)
end)

→ In log mode, you’ll get table’s memory address.

Debug id is restricted to plugin security iirc. And it’s mainly intended for debugging, not general use. Still unique reference tho :+1:

3 Likes

I know i was talking about if he was using it for a plugin or just 1time commandline use

3 Likes