I'm using an basic Data Saving script I'm not getting any errors. But it's not saving the cash is it because where the Money value is being stored? Script:
local DataStoreService = game:GetService("DataStoreService")
local MoneyData = DataStoreService:GetDataStore("MoneyData")
local Players = game:GetService("Players")
game.Players.PlayerAdded:Connect(function(player)
local Money = player.PlayerGui:WaitForChild("MoneyValue").PlayerStat.MoneyValue.Value
local Data
local success, errormessage = pcall(function()
Data = MoneyData:GetAsync(player.UserId.."-Money")
end)
if success then
Money = Data
else
print("DataNotStored")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
MoneyData:SetAsync(player.UserId.."-Money",player.PlayerGui.MoneyValue.PlayerStat.MoneyValue.Value)
end)
if success then
print("DataStored")
else
print("DataNotStored")
warn(errormessage)
end
end)