I Have an issue with my datastore leaderstats

At line 29, you are still referencing to player.leaderstats. It should be player.leaderboard
After that, it should all work correctly.

I tried it but not working again… here is the code

local DataStoreService = game:GetService("DataStoreService")

local playerData = DataStoreService:GetDataStore("playerMoney")

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderboard"
	leaderstats.Parent = player

	local money = Instance.new("IntValue")
	money.Name = "Money"
	money.Parent = leaderstats

	local data 
	local success, errormessage = pcall(function()
		data = playerData:GetAsync(player.UserId.."-money") 
	end)

	if success then 
		money.Value = data
	else
		print("Error while getting your data")
		warn(errormessage)
	end
end)

local function SavePlayerData(player)
	local success, errormessage = pcall(function()
		playerData:SetAsync(player.UserId.."-money", player.leaderboard.Money.Value)
	end)

	if success then
		print("Data successfully saved!")
	else
		print("There was an error while saving the data")
		warn(errormessage)
	end
end

game.Players.PlayerRemoving:Connect(SavePlayerData)


game:BindToClose(function()
	for _,Player in pairs(game:GetService("Players"):GetPlayers()) do
		pcall(function()
			SavePlayerData(Player)
		end)
	end
	wait(5)
end)

This works for me. Are you able to specify which part isn’t working?

Its not saving data but leaderboard is working fine

Is it printing Data successfully saved? If not, recopy the code from above. I did a minor change that should fix that.

I tried your code but not working again its not printing Data successfully saved

No errors? I don’t know why it is working for me but not for you.

I really dont know my brain is stopped working

Could you save your game and send it here or in dms?

I can send you on discord come do you have discord

Check Devforum Messages (aaaa)

Solved it. OP was editing money value from client window, not server window.