DataStore not working

You can write your topic however you want, but you need to answer these questions:
I made this datastore leaderstats script but it doesn’t save. The script gives off no errors so I dont know how to fix it.

  1. I have tried to compare my script to other data store scripts but I still dont know what the problem is.

API services is on.

   local dataStore = game:GetService("DataStoreService")

local playerData = dataStore:GetDataStore("playerData")
game.Players.PlayerAdded:Connect(function(plr)

	local leaderstats = Instance.new("Folder")
	leaderstats.Parent = plr
	leaderstats.Name = "Data"

	local Evo = Instance.new("IntValue")
	Evo.Parent = leaderstats
	Evo.Name = "Evo" 
	Evo.Value = 0 
	local Weapon = Instance.new("IntValue")
	Weapon.Parent = leaderstats
	Weapon.Name = "Weapon" 
	Weapon.Value = 0 
	local Armor = Instance.new("IntValue")
	Armor.Parent = leaderstats
	Armor.Name = "Armor" 
	Armor.Value = 1
	local Race = Instance.new("IntValue")
	Race.Parent = leaderstats
	Race.Name = "Race" 
	Race.Value = 0 
	
	local playerUserId = "Player_"..plr.UserId

	local data
	local success, errormessage = pcall(function()
		data = playerData:GetAsync(tostring(playerUserId))
end)
	if success then
		Evo.Value = data
		Weapon.Value = data
		Armor.Value = data
		Race.Value = data
	else
		print("Error while getting your data")
		warn(errormessage)
	end
end)


game.Players.PlayerRemoving:Connect(function(player)
	local success, errormessage = pcall(function()
		playerData:SetAsync(player.UserId.."-Evo", player.Data.Evo.Value)
		playerData:SetAsync(player.UserId.."-Weapon", player.Data.Weapon.Value)
		playerData:SetAsync(player.UserId.."-Armor", player.Data.Armor.Value)
		playerData:SetAsync(player.UserId.."-Race", player.Data.Race.Value)
	end)

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

I edited your script, this Should work. I didn’t tested it.

If it’s not working tell me.

Here I added an auto-saver also, THIS WORKS.

Working Script
local dataStore = game:GetService("DataStoreService")
local playerData = dataStore:GetDataStore("playerData")

function save(player)
	print('Saving data for: '..player.Name)
	---------------------------------------
	local success, errormessage = pcall(function()
		local sdata = {}
		sdata["Evo"] = player.Data.Evo.Value
		sdata["Weapon"] = player.Data.Weapon.Value
		sdata["Armor"] = player.Data.Armor.Value
		sdata["Race"] = player.Data.Race.Value
		playerData:SetAsync(player.UserId, sdata)
	end)

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

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

	local leaderstats = Instance.new("Folder")
	leaderstats.Parent = plr
	leaderstats.Name = "Data"

	local Evo = Instance.new("IntValue")
	Evo.Parent = leaderstats
	Evo.Name = "Evo" 
	Evo.Value = 0 
	local Weapon = Instance.new("IntValue")
	Weapon.Parent = leaderstats
	Weapon.Name = "Weapon" 
	Weapon.Value = 0 
	local Armor = Instance.new("IntValue")
	Armor.Parent = leaderstats
	Armor.Name = "Armor" 
	Armor.Value = 1
	local Race = Instance.new("IntValue")
	Race.Parent = leaderstats
	Race.Name = "Race" 
	Race.Value = 0 
	
	plr.CharacterAdded:Wait()
	
	local data
	local success, errormessage = pcall(function()
		data = playerData:GetAsync(plr.UserId)
	end)
	if success then
		Evo.Value = data["Evo"]
		Weapon.Value = data["Weapon"]
		Armor.Value = data["Armor"]
		Race.Value = data["Race"]
		
		print('Data Loaded for '..plr.Name)
	else
		print("Error while getting your data")
		warn(errormessage)
	end
end)


game.Players.PlayerRemoving:Connect(function(player)
	save(player)
end)

while wait(60) do
	for i,v in pairs(game:GetService('Players'):GetPlayers()) do
		save(v)
	end
end

Also, im testing it. You need to add a pcall function when setting values. So if a player is new, to not log an error to the console.