I'm trying to save a player's data, but it does not appear to save. It gives no errors, and also used to work. It just randomly stopped working
local Data = game:GetService("DataStoreService"):GetDataStore("Cash")
game.Players.PlayerAdded:Connect(function(plr)
local Folder = Instance.new("Folder",game.ServerStorage)
Folder.Name = plr.Name
local Cash = Instance.new("IntValue",Folder)
Cash.Name = "Cash"
local Levels = Instance.new("IntValue",Folder)
Levels.Name = "Levels"
local SavedItems = Data:GetAsync(plr.userId)
wait(.1)
if SavedItems then
Cash.Value = SavedItems.Cash or 0
Levels.Value = SavedItems.Levels or 0
else
Cash.Value = 0
Levels.Value = 0
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local Saving = {
["Cash"] = game.ServerStorage:FindFirstChild(plr.Name).Cash.Value;
["Levels"] = game.ServerStorage:FindFirstChild(plr.Name).Levels.Value}
Data:SetAsync(plr.userId,Saving)
end)

1 comment
do you have API services on?