Best/Easiest way to save player data

I’ve got a game that currently uses the BadgeService to detect if players have unlocked a certain accessory or not that becomes accessible in an equip menu.
The badge service however consistently breaks due to getting too many requests in too little time as there are a lot of accessories that check if they are unlocked or not.
I’ve had to make work arounds such as adding refresh buttons and buttons to fix the script if it happens to break due to hitting the limit.
I know datastores are a great way to do this and I’ve researched them a lot as well as looked at many different modules but I just cannot wrap my head around them for the life of me and I am desperate for some more help.

Tldr: Need help figuring out the easiest way to save data (boolean) that detects if a player has unlocked an accessory as well as how to do it and where to put everything.

Instead of having a table that stores boolean values for each accessory such as this:

list = {
	["AccessoryA"] = true,
	["AccessoryB"] = false,
	["AccessoryC"] = true,
	["AccessoryD"] = false,
	["AccessoryE"] = false
}

You can instead make it a list and store the accessories the player has. Then use table.find to check if the player has that accessory.

list = {
	"AccessoryA",
	"AccessoryC"
}

print(table.find(list, "AccessoryA"))

Hey @xNotM4x !

The easiest way around the data stores from my experience is Profile Service. Of course, you will have to set it up and read instructions first, which shouldn’t take longer than an hour for beginners, but it is a very easy way to work around your data.

Hope that helps!

Put a Remote Event in ReplicatedStorage and name it “RemoteEventSave”
Put a Remote Event in ReplicatedStorage and name it “RemoteEventSave1”
Put this script in a Script and put it in ServerScriptService

local DataStore = game:GetService("DataStoreService"):GetDataStore("DataStoreTest")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local RemoteEventSave = ReplicatedStorage:WaitForChild("RemoteEventSave")
local PlayerBase = game.Players.LocalPlayer
local plr = game.Players:FindFirstChild("Player")

game.Players.PlayerAdded:Connect(function(player)
	local Value = Instance.new("NumberValue", player)
	Value.Name = "SaveFile"
	
	local folder1 = Instance.new("Folder", player)
	folder1.Name = "ValueFolder1"
	
	local Value1 = Instance.new("NumberValue", folder1)
	Value1.Name = "SaveFile1"


	local stats = DataStore:GetAsync(player.UserId)
	
	if stats ~= nil then
		Value.Value = stats[1]
		Value1.Value = stats[2]
	else
		Value.Value = 0
		Value1.Value = 0
	end
end)

game.ReplicatedStorage.RemoteEventSave1.OnServerEvent:Connect(function(player)
	local save = {}

	table.insert(save, player.SaveFile.Value)
	table.insert(save, player.ValueFolder1.SaveFile1.Value)

	DataStore:SetAsync(player.UserId, save)
	print("ahahahahahahahhahaSaved")
end)

Put a screengui with a frame in it, put that in ScreenGui and put a LocalScript in the frame with this code

local button = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEventSave1")

local part = script.Parent

game.ReplicatedStorage.RemoteEventSave.OnClientEvent:Connect(function()
	remoteEvent:FireServer()
end)

I didn’t make all of this script and it’s a little overdo but pretty simple as well

Yeah, don’t do this. It’s impossible to expand once you add more and more badge checks, and you’re going to run into issues as you’ve already discovered.

Another poster mentioned using ProfileService which is probably one of the better ways to store data. I would also recommend DataStore2 which IMO is much simpler as it doesn’t call for boilerplate code.

I would not recommend you try implementing datastores on your own because it’s easy to get it wrong (just view my recent history and you’ll see what I mean.)

If you’re gonna use modules for saving data (which I absolutely recommend you do) I recommend Suphi’s Datastore Module above anything else as Datastore2 is outdated and Profile Service has it’s own problems that has been pointed out by Suphi himself.

Did everything you said and it gives me the following error: Argument 1 missing or nil - DataManager(serverscriptservice) line 19. If you’re able to help me with fixing it I can give it a shot but I feel like I might just need a hand using one of the modules I’ve been told to use.

I’ve spent the last 3 days figuring out how to use Profile Service and I have genuinely no idea how to make it work the way I want it to, I’ve tried following tutorials and everything and it is very overwhelming compared to what I normally work with or try to learn.
I’d appreciate some sort of script or code with comments to break down a basic way to store data using the profile service and where all the scripts and whatnot need to go.

Yeah when I first started researching saving data I tried to make my own datastore a few times and it is no walk in the park if you don’t know what you’re doing, I just struggle just as much with the modules which sucks.

Yeah @xNotM4x , learning data stores might be an overwhelming experience for beginners and a tough pill to swallow. We’ve all been there, believe me!

But this is an important challenge if you want to script by yourself instead of looking for a code in the web. Accept that it will take time, and go there step by step until it works.

Once again, Profile Service is the easiest I’ve seen so far. Read the whole Wiki Page about the method (basically takes 10 minutes). There is code with the comments as well!

btw forgot to ask did you turn on API in the game settings
if not:
Go to game settings
go to Security
turn on “Enabled Studio Access to API Services”

Sorry my bad changed
fixed it now here:
Remove:
while wait(1) do
RemoteEventSave:FireClient()
end
from the script

next make a button in screen gui with this script remember to make a screen gui in screengui with a button in it

local RemoteEvent2 = game.ReplicatedStorage:WaitForChild("RemoteEventSave1")
local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	while task.wait(1) do
	RemoteEvent2:FireServer()
	print("SaveSent")
end
end)

If it says “SaveSent” and “ahahahahahahahaSaved” in the Output tab it works
even if your values don’t save then u just need to use remotes but i can help with that if you can put this in