What the point of using key with player.UserId-string?

I have seen alot of datastores scripts and most of the time they use `player.UserId-something. I always wonder what point of using this, isn’t the userId already unique?


    local Data
	local success,errormessage = pcall(function()
		Data = DataStore:GetAsync(player.UserId .. "-Cash")

This is something always got me confused.

There’s nothing really ‘crazy’ about it, It’s just a way for making things simpler, so instead of making a single very big datastore all into player.UserId you can separate them in those sections, like “Cash”, “Options” and etc.

Of course if you want to make a single datastore containing all of the sections in player.UserId you can.

1 Like

This comes from a bad practice that started around the conception of DataStores, which is that every data value for a player should be assigned a separate key in a DataStore (the DataStores themselves were mostly already uniquely named so this was pointless).

Nowadays as developers are more familiar with DataStoreService and have developed their own systems to get the best use of DataStores including battle-tested modules, this is a relic of the past. Most developers, even novice ones, understand that you should be saving dictionaries as the value to a UserId key for a single DataStore.

Never follow this pattern. It’s not simple, it’s not good and no one should recommend it. It’s a simple way of running into rate limits, yes, otherwise if you’re looking to get the best use of your DataStores then you should be using dictionaries instead.