function PlayerStatManager.saveOnExit(e,t)local o,R=pcall(function()local e=serverStorage.PlayerMoney:FindFirstChild(t.Name)if e~=nil then PlayerStatManager:saveStat(t,"\077\111\110\101\121",e.Value)else print("\112\108\097\121\101\114\115\077\111\110\101\121 \105\115 \110\105\108")end local o="\080\108\097\121\101\114\095"..t.UserId savePlayerData(o)end)if o==false then warn("\069\082\082\079\082---------\080\108\097\121\101\114\083\116\097\116\077\097\110\097\103\101\114\058\115\097\118\101\079\110\069\120\105\116-----------\062")print(R)end end function PlayerStatManager.setAllTycoonPurchasesToNil(e,t)local o="\080\108\097\121\101\114\095"..t.UserId local R=sessionData[o].TycoonPurchases for t,e in pairs(R)do sessionData[o].TycoonPurchases[t]=nil end end
-- Function to save player data on exit
function PlayerStatManager:saveOnExit(player)
	local success, err = pcall(function()
		local playersMoney = serverStorage.PlayerMoney:FindFirstChild(player.Name)
		if playersMoney ~= nil then
			--print("--------------playersMoney.Value = "..playersMoney.Value)
			PlayerStatManager:saveStat(player, "Money", playersMoney.Value)
		else
			print("playersMoney is nil")
		end
		local playerUserId = "Player_" .. player.UserId
		savePlayerData(playerUserId)
	end)
	if success == false then
		warn("ERROR---------PlayerStatManager:saveOnExit----------->")
		print(err)
	end
end

function PlayerStatManager:setAllTycoonPurchasesToNil(player)
	local playerUserId = "Player_" .. player.UserId
	local data = sessionData[playerUserId]["TycoonPurchases"]
	for key, value in pairs(data) do
		sessionData[playerUserId]["TycoonPurchases"][key] = nil
	end
end
