What are all of the Datastore Services that can be used to store player data and object related data caused by the player?

What are all of the Datastore Services that can be used to store player data and object related data caused by the player?

The Only one’s I know are:

Reg DataStores and ProfileService.

Regular Datastores never work for me and ProfileService is a little bit to complex for my tiny brain.

Here’s a system that I use, it’s small, sweet, and simple.

Code
local DATA_TEMPLATE = { -- your data here
	
}
local data = {}
local data_cache = {}
local DS = game:GetService("DataStoreService"):GetDataStore("YourDS")
local Players = game:GetService("Players")

function data.onPlayerAdded(player)
	local data = DS:GetAsync("UID_"..player.UserId) or DATA_TEMPLATE

	for index, value in pairs(DATA_TEMPLATE) do
		if not data[index] then
			data[index] = value
		end
	end

	data_cache[player] = data
end
function data.get(player)
	return data_cache[player]
end

function data.set(player)
	local success, err = pcall(function() DS:SetAsync("UID_"..player.UserId, data_cache[player]) end)
	if not success then
		print(err)
	end
end


return data

Let me know if you’d like an example.

1 Like

Can you possibly explain some of this for me? a bit confused.

And also why did you put return data?

Okay, so. Let’s say your data template is this:

local DATA_TEMPLATE = {
    Level = 1,
    XP = 0
}

It’s what your players are going to start off with.

This will be ran when a player joins, so just pass in that player argument.

This returns the player’s data in the cache. The cache is what stores the data of all of the players. Example:

local data_ = data.get(player)
data.Level = 1000

This will set our data after we update it. Example:

local data_ = data.get(player)
data.Level = 1000
data.set(player)

Because it’s in a module script

1 Like

Outside of this script, Is their a way I can get a value for Dummy EXP?

Im trying to make it so that every time the Dummy completes the obby, a script will give the Dummy Xp but how can I get the value without it being in the Module Script?

Store an IntValue instance inside the ServerStorage folder, increase its value when the dummy completes the obby.

How would I make the game Auto Load the players progress? e.x, Money, NPC Levels, Special Currency’s, Multipliers, etc…

Also, Whenever the player buys a Obby level, how would I call their current money value without having leaderstats?