I'm having problems with Data Store

Ok, but sometimes the output appears on PlayerRemoving with 1 client on studio, and it’s the success message.

And when you start the test again the correct value loads? If it doesnt you need to check the value you’re saving. This plugin is great for seeing what the datastore has as the value. Your userid’s are either -1 or -2.

Print the value saved in Coins when you go to save so you can verify it isnt nil.

Ok, but the plugin costs 150 robux, and I don’t want to pay 150 robux in this.

Then paste a GetAsync snippet into the command bar and print the value saved. Printing the results of the GetAsync and coins.Value when you SetAsync will allow you to verify proper data values in the local test.

I did this, and the Async value is 0.

You mean the coin.Value at save time?

If that’s 0 and you’re loading in with 0 then everything is working here.

I mean the coin.Value at the Get Data time.

Like loaded from GetAsync()? If so and if you’re not changing Coins.Value then it will save that value as 0 again. NumberValues default to 0 when you create them.

I’m changing the Coins.Value, and the value is always 0.

If the value is still 0 at save time then something has gone wrong with the bit that changes coins.Value.

I tried to print the data in save time, and it prints “nil”.

I made changes in the script:

local DataStore = game:GetService("DataStoreService")--:GetDataStore("MyDataStore")
local SaveData = DataStore:GetDataStore("SaveData")
local plrService = game:GetService("Players")

function GetPlrData(player)
	wait()
	local SaveValue = player.plrstats.Coins
	local plrkey = "Coins_"..player.UserId
	
	local GetData
	local success, err = pcall(function()
		GetData = SaveData:GetAsync(plrkey)
	end)

	if success then
		print("Got Data Successfully")
		SaveValue.Value = GetData or 0
		
		if GetData == nil then
			print("Data is nil")
		else
			print(GetData)
		end
	else
		warn(err)
		print("Error on getting data.")
	end
end

function SavePlrData(player)
	local Data
	local success, err = pcall(function()
		Data = SaveData:SetAsync("Coins_"..player.UserId, player.plrstats.Coins.Value)
	end)
	
	if success then
		print("Saved Successfully")
		print(Data)
	else
		warn(err)
		print("Error on saving data.")
	end
end

plrService.PlayerAdded:connect(GetPlrData)
plrService.PlayerRemoving:connect(SavePlrData)

I found the error: the way I was using to change the data. Thank you all that helped me.