Here I have a script for saving leaderstats, but it doesn't work? Any help would be appreciated!
local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("CashSaveSystem")
game.Players.PlayerAdded:Connect(function(plr)
local folder = Instance.new("Folder",plr)
folder.Name = "leaderstats"
local cash = Instance.new("IntValue",folder)
cash.Name = "Cash"
cash.Value = ds1:GetAsync(plr.UserId) or 0
ds1:SetAsync(plr.UserId, cash.Value)
game.Players.PlayerRemoving:Connect(function(plr)
ds1:SetAsync(plr.UserId, cash.Value)
end)
end)
