Datastore script doesn't works

Hi, this datastore script is not loading and saving data correctly
It always says in the console: failed to load data of the player

local DataStoreService = game:GetService("DataStoreService")
local CashDataBase = DataStoreService:GetDataStore("CashData")
local MissionsDataBase = DataStoreService:GetDataStore("MissionsData")

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

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

	local Cash = Instance.new("IntValue")
	Cash.Name = "Cash"
	Cash.Value = 0
	Cash.Parent = leaderstats

	local MissionsData = Instance.new("IntValue")
	MissionsData.Name = "MissionsData"
	MissionsData.Value = 0
	MissionsData.Parent = PlayerData
	local playercash
	local playermissions
	local success, result = pcall(function()
		playercash = CashDataBase:GetAsync(player.Userid)
	end)

	local success2, result2 = pcall(function()
		playermissions = MissionsDataBase:GetAsync(player.Userid)
	end)
	if success then
		Cash.Value = playercash
	else
		warn("There was a error loading the cash data of the player: " .. player.UserId)
	end
	if success2 then
		MissionsData.Value = playermissions
	else
		warn("There was a error loading the missions data of the player: " .. player.UserId)
	end
	game.Players.PlayerRemoving:Connect(function(player)

		local success, result = pcall(function()
			return CashDataBase:SetAsync(player.UserId, Cash.Value)
		end)

		local success2, result2 = pcall(function()
			return MissionsDataBase:SetAsync(player.UserId, MissionsData.Value)
		end)

		if success then
			print("Successfully saved the cash data of the player: " .. player.UserId)
		else
			warn("There was a error saving the cash data of the player: " .. player.UserId)
		end

		if success2 then
			print("Successfully saved the missions data of the player: " .. player.UserId)
		else
			warn("There was a error saving the missions data of the player: " .. player.UserId)
		end
		return success, success2
	end)
end)

What is the error message exactly

(EDIT: while reading this the only problem i can think off is that your checking for player data and if there isn’t any it just gives a warning, instead of creating any data. so if no data is being saved, then itll never be able to find any.

Which still doesnt make sense because it looks like it would save data anyway because of the player leaving script. and the script wouldnt break because of the warning because its in a pcall)

First of all, Userid is incorrect here

Change it to UserId.

Secondly, use the PlayerRemoving event out of the PlayerAdded event.