Leaderstats DataSave

So i have made a script that works it saves tool but i cant figure out how to save the leaderstats

1 Like

Use DataStore. A popular wrapper for DataStoreService is DataStore2

If you know how to save tools, then it works similarly. You just save the value of each thing in leaderstat and then load it when they rejoin.

2 Likes

i already used a data store the coins worked and saved before but when i enabled this data script it canceled out the leaderstat save

local ToolFolder = game:GetService(“ServerStorage”):FindFirstChild(“SavedTools”)
local DataStoreService = game:GetService(“DataStoreService”)
local SaveData = DataStoreService:GetDataStore(“SaveData”)

game.Players.PlayerAdded:Connect(function(Player)
local ToolData = SaveData:GetAsync(Player.UserId)

local Backpack = Player:WaitForChild("Backpack")
local StarterGear = Player:WaitForChild("StarterGear")

if ToolData ~= nil then
	for i, v in pairs(ToolData) do
		if ToolFolder:FindFirstChild(v) and Backpack:FindFirstChild(v) == nil and StarterGear:FindFirstChild(v) == nil then
			ToolFolder[v]:Clone().Parent = Backpack
			ToolFolder[v]:Clone().Parent = StarterGear
		end
	end
end

Player.CharacterRemoving:Connect(function(Character)
	Character:WaitForChild("Humanoid"):UnequipTools()
end)

end)

game.Players.PlayerRemoving:Connect(function(Player)
local ToolTable = {}

for i, v in pairs(Player.Backpack:GetChildren()) do
	table.insert(ToolTable, v.Name)
end
if ToolTable ~= nil then
	SaveData:SetAsync(Player.UserId, ToolTable)
end

end)

1 Like

those are both the same script btw

1 Like

Do you want to make it on the same data store ?

1 Like

no i want
it to be a seperate script

1 Like

1 Like

i cant really see text can you either put camera closer or paste it?

1 Like

I’m not at my home I’m in a car

1 Like

But wait I gonna try to find something

1 Like

Make sure your using a Script and not a LocalScript

1 Like


1 Like

Copy this and change the currency money by putting your currency on each Cash

ok i will try that thanks i dont like char limitttt

Ye also make sure that the scripts that give you your currency value are script and not local scripts cuz if it’s local then the server can’t get the real currency value

2 Likes

ait on the first image on the button of the image make sure do put Cash.Parent = leaderstats

???wdym

1 Like

what do you mean by ait on the first image on the button of the image make sure do put Cash.Parent = leaderstats

1 Like

can you edit the script around the object coins that is my currency

they mean add that into the script so underneath Cash.Value put Cash.Parent = leaderstats