Leaderstats DataSave

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

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.

1 Like

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)

those are both the same script btw

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

no i want
it to be a seperate script

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

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

But wait I gonna try to find something

Make sure your using a Script and not a LocalScript


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

1 Like

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

???wdym

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

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