I am trying to get the instance’s hexadecimal reference in memory, however I don’t know how to access it. I know that when you set the key of a dictionary as an object it will use the hexadecimal reference as the key in string form, however I don’t know how I access that string.
See solution to this similar post.
Reminder that we have no real memory access methods in ROBLOX. Don’t know why you would be trying to access this – if you’re looking to use it as a unique identifier, just use
I’m creating a state manager to keep track of player’s states, and I want to make it so we can easily access a character’s states, the issue with using char.Name is that if we have NPC with the same name it will have reference issues.
There is a function for it called :GetDebugId() but it’s locked to context level 3 I believe
Player as in NPC or actual character?
You shouldn’t be using keys that are at risk of being the same to track data for unique instances. You’re just asking for problems like these.
If it’s for an NPC, use a GUID anyways instead of a name as a reference. Practically zero chance of collision (use two if you are truly paranoid, or combine it with something like
os.time() for more separation). Alternatively, you can use some sort of hashing algorithm to generate unique keys for every character’s state.
If it’s an actual player, just use their
UserId, which is gauranteed to be unique per-player.
Just use the Player/Character instance directly as the key. You will have to make sure it is removed from the hashmap when the player is destroyed, though, since instances won’t GC if they are referenced as keys regardless of the table’s mode.
Do this, the Instance object itself is unique and thus a good key.
That’s what I been doing, as the key, but I need a unique name for the character’s folder I was trying to use the key as the folder but couldnt