Hello again, I am using the DataStore service to save a player's money. There are no errors in the output, but the amount of cash I enter in the value doesn't save. Again, I am using AlvinBlox's tutorial. Here is the entire code:
local CurrencyName = "C01nz"
local DataStore = game:GetService("DataStoreService"):GetDataStore("TestDataStore")
game.Players.PlayerAdded:Connect(function(player)
local Folder = Instance.new("Folder")
Folder.Name = "leaderstats"
Folder.Parent = player
local Currency = Instance.new("IntValue")
Currency.Name = CurrencyName
Currency.Parent = Folder
local ID = CurrencyName.."="..player.UserId
local SavedData = nil
pcall(function()
SavedData = DataStore:GetAsync(ID)
end)
if SavedData ~= nil then
Currency.Value = SavedData
print("Data loaded.")
else
-- New Player1!!111
Currency.Value = 0
print("A new player")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local ID = CurrencyName..":"..player.UserId
DataStore:SetAsync(ID,player.leaderstats[CurrencyName].Value)
print("Data Saved")
end)
game:BindToClose(function()
--When game is ready to shutdown
for i, player in pairs(game.Players:GetPlayers()) do
if player then
player:Kick("This game is shutting down.")
end
end
wait(5)
end)
There are no errors in the output, and I looked at the tutorial numerous times, so I am really stumped. Help would be appreciated.
