local Q=game:GetService("\068\097\116\097\083\116\111\114\101\083\101\114\118\105\099\101")local c=Q:GetDataStore("\112\108\097\121\101\114\068\097\116\097")game.Players.PlayerAdded:Connect(function(Q)local k=Instance.new("\070\111\108\100\101\114")k.Name="\108\101\097\100\101\114\115\116\097\116\115"k.Parent=Q local s=Instance.new("\073\110\116\086\097\108\117\101")s.Name="\067\097\115\104"s.Parent=k local i local K,r=pcall(function()i=c:GetAsync(Q.UserId.."-\099\097\115\104")end)if K then s.Value=i else print("\069\114\114\111\114 \119\104\105\108\101 \103\101\116\116\105\110\103 \121\111\117\114 \100\097\116\097")warn(r)end end)game.Players.PlayerRemoving:Connect(function(Q)local k,s=pcall(function()c:SetAsync(Q.UserId.."-\099\097\115\104",Q.leaderstats.Cash.Value)end)if k then print("\068\097\116\097 \115\117\099\099\101\115\115\102\117\108\108\121 \115\097\118\101\100\033")else print("\084\104\101\114\101 \119\097\115 \097\110 \101\114\114\111\114 \119\104\105\108\101 \115\097\118\105\110\103 \116\104\101 \100\097\116\097")warn(s)end end)
--[[
	3/19/20
	newwil
	DataStore/Leaderstats
--]]

local DataStoreService = game:GetService("DataStoreService")

local playerData = DataStoreService:GetDataStore("playerData")

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

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

	local data
	local success, errormessage = pcall(function()
		data = playerData:GetAsync(player.UserId .. "-cash")
	end)

	if success then
		cash.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 .. "-cash", player.leaderstats.Cash.Value)
	end)

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