I really need help solving this, here is the script:

local DataStoreService = game:GetService("DataStoreService") local Coke = DataStoreService:GetDataStore("Coke")

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 Rebirths = Instance.new("IntValue")
Rebirths.Name = "Rebirths"
Rebirths.Parent = leaderstats

local playerUserId = "Player_"..player.UserId

-- Load Data

local dta
local success, errormessage = pcall(function()
	data = Coke:GetAsync(playerUserId)
end)

Cash.Value = data.Cash
Rebirths.Value = data.Rebirths


if success then
	if data then
		Cash.Value = data
		Rebirths.Value = data
	-- Set our data equal to the current cash
end

end)

game.Players.PlayerRemoving:Connect(function(player) local playerUserId = "Player_"..player.UserId

local data = {
	Cash = player.leaderstats.Cash.Value;
	Rebirths = player.leaderstats.Rebirths.Value;
}


local success, errormessage = pcall(function()
	
end)
Coke:SetAsync(playerUserId, data)

if success then
	print("Data succsesfully saved!")
else
	print("There was a error!")
	warn(errormessage)
end

end)

1 comment

0

maybe use formatting?