How to make Leaderstats with Data Save

Hello i need help how to make leaderstats with data save or data store but i know how to make leaderstats except data save don’t know how to do it

6 Likes

Open Roblox Studios → Game Settings → Security → Enable Studio Access to API Services
It will then save the data of your game, no need to add any script.

4 Likes

Why does that look like an AI generated reply bro… :pray:

Anyways that’s NOT how you use datastores.

You need to use datastores by using DataStoreService.

Read the documentation.

4 Likes

What about global leaderboard it will save too?

3 Likes

First of all, this is the wrong category, please move this to #help-and-feedback:scripting-support.

That user is wrong, you need to have a script to save and load data.

Here is an examp

local RemoteEvents = game.ReplicatedStorage.RemoteEvents
local HTTPService = game:GetService("HttpService")
local LegalAct = RemoteEvents.LegalAct

local msgS = require(game.ReplicatedStorage.MessageSender)

local DataStoreService = game:GetService("DataStoreService")
local LegalStore = DataStoreService:GetDataStore("LegalStoreA1")

LegalAct.HasAgreed.OnServerInvoke = function(player)
	local success,data = pcall(function()
		return LegalStore:GetAsync("Legalities")
	end)
	if success and data then
		if table.find(HTTPService:JSONDecode(data),player.UserId) then
			return true
		end
	end
	return false
end

LegalAct.Agreed.OnServerEvent:Connect(function(player)
	local success,data = pcall(function()
		return LegalStore:GetAsync("Legalities")
	end)
	if success then
		if data then
			data = HTTPService:JSONDecode(data)
			table.insert(data,player.UserId)
			msgS.Embed(player,"Contract Agreement","Player agreed to TOS.","I")
		else
			data = {player.UserId}
		end
	end
	LegalStore:SetAsync("Legalities",HTTPService:JSONEncode(data))
end)

I made this for my game but this basically helps you understand how datastore works.

3 Likes

It’s not though, but it works for me

2 Likes

they are because they said that udon’t need any script while u do. they only told you how to enable data store api.

3 Likes

DataStoreService basically saves anything but if you want to make a global leaderboard that is ordered then you need OrderedDataStoreService. Its like a subsection of DataStoreService,

Learn more here:

2 Likes

Thanks you very much for telling me how to do it

1 Like

No problem! Let me know if you have any other issues and I’ll happily fix them. :blush:

1 Like