Money wont save

this is what im doing to change the leader stat image image image

but are you currently in server perspective?

yes i am in the server perspective

I will write you a data store code based off yours

thank you Liam. :smiley: :+1: .

I did not tested it, but I believe it should work fine.

local DataStore = game:GetService("DataStoreService"):GetDataStore("PlayerData")

game.Players.PlayerAdded:Connect(function(player)

	local folder = Instance.new("Folder")
	folder.Name = "leaderstats"
	folder.Parent = player	

	local currency = Instance.new("IntValue")
	currency.Name = "Coins"

	local ok, result = pcall(DataStore.GetAsync, DataStore, player.UserId)

	if ok then -- you must check if you successfully retrieved the data
		
		if result then -- if the player has data
			currency.Value = result
		else -- if the player doesn't have data
			currency.Value = 5
		end
		
		currency.Value += 5 -- every time you play the game the currency will increase by 5, this will let you know if the data is saving
		
		currency.Parent = folder -- you should always make changes and then parent the Instance
	else
		warn(result) -- if we failed to retrieve data, result will be a warning message
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	local Coins = player.leaderstats.Coins
	local ok, result = pcall(DataStore.SetAsync, DataStore, player.UserId, Coins.Value)
	
	if ok then -- if we successfully saved the data
		warn("data has been saved")
	else
		warn(result) -- once again, if we failed, result will be a warning message
	end
end)

game:BindToClose(function()
	for _,player in ipairs(game.Players:GetPlayers()) do
		coroutine.wrap(function()
			local Coins = player.leaderstats.Coins
			pcall(DataStore.SetAsync, DataStore, player.UserId, Coins.Value) -- we don't need to check there because its pointless (not in studio).
		end)
	end
end)

so that should work for me? ill test it out now

ok i got 10 coins now let me leave and join back

ok i still got 10 coins let me add more on to see if that works

if its not working, there should be warning message in your output pointing what’s wrong and what you shall fix

its not working ill tell you the script warning messages now
huh thats odd there is non

I have tested it right now and its working perfectly fine for me, make sure you have API Services enabled in game settings > security > Data Store > Enable studio access to API Services, if it still doesn’t work, test it in game not in studio.

image its always been on

I have no clue what’s happening then, it is working fine at least for me, are you using a script that is located in ServerScriptService?

yes the script is there image

Try to change once again the DataStore name.

ok i changed the data store name ill try again

ok im confused now ive done all of that i set it to 4k now its back on 10

can you send a screenshot of your output?

here image