I am trying to save some values but it isn't working
local dataStores = game:GetService("DataStoreService") local cashDataStores = dataStores:GetDataStore("CashDataStore")
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.Value = cashDataStores:GetAsync(player.UserId.."_Cash")
Cash.Parent = leaderstats
end)
game.Players.PlayerRemoving:Connect(function(player)
local cashSavingData = player.leaderstats.Cash.Value
cashDataStores:SetAsync(player.UserId.."_Cash", cashSavingData)
end)

2 comments
Are you testing in studio? If so, do you have API services enabled
What errors if any are you getting in the console?