Heres code:
local DataStoreService = game:GetService("DataStoreService")
local Cashdatastore = DataStoreService:GetDataStore("CashDS")
game.Players.PlayerAdded:Connect(function(Player)
local Cash = Instance.new("NumberValue")
Cash.Name = "Cash"
Cash.Parent = Player
local Success, Error
Success, Error = pcall(function()
Data = Cashdatastore:GetAsync(Player.UserId)
end)
if Success then
if Data then
Cash.Value = Data
print("Loaded "..Player.UserId)
else
Cash.Value = 500
print(Player.Name.." is new to the game")
end
else
print(Error)
end
end)
--------------------------------Saving part----------------------------------------
game.Players.PlayerRemoving:Connect(function(Player)
local success, errorMsg
success, errorMsg = pcall(function()
Cashdatastore:SetAsync(Player.UserId, Player.Cash.Value)
end)
if success then
print("Saved "..Player.UserId)
else
print(errorMsg)
end
end)
I only get this in output:
i have two more datastores that are working