For a bit more detail, everything is enabled in this game. This effects both in and out of studio. I've tried the common form of saving leaderstats. This is the script I am using for my leaderstats:
local ds = game:GetService("DataStoreService"):GetDataStore("LeaderStore")
nc0 = "Z-Bucks"
nc1 = "Waves"
sc0 = 0
sc1 = 0
game.Players.PlayerAdded:Connect(function(player)
wait(0.1)
local savedLevel = ds:GetAsync(player.UserId)
local coins = player.leaderstats["Z-Bucks"]
local coins1 = player.leaderstats.Waves
if savedLevel then
coins.Value = savedLevel[1]
coins1.Value = savedLevel[2]
else
coins.Value = sc0
coins1.Value = sc1
ds:SetAsync(player.UserId,{coins.Value, coins1.Value})
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local stats = player:FindFirstChild("leaderstats")
if not stats then return end
local vals = {stats:FindFirstChild(nc0),stats:FindFirstChild(nc1)}
if vals and vals[1] and vals[2] then
ds:SetAsync(player.UserId,{vals[1].Value, vals[2].Value})
end
end)
If you could provide a script that works that will be appreciated!

3 comments
You're not initializing the leaderstats folder in the first place
That and please you should use a pcall for Datastores and everyting Async because Errors are a lot more likely there
I already have a leaderstats. But how would I use pcall and async? I am not that good at coding.