A am trying to save a leaderstat called "coins" but it wont save and it makes two leaderstats one named "Coins" and one named "coins" with a lowercase c.
game.Players.PlayerAdded:Connect(function(plr)
local stats = Instance.new("IntValue",plr)
stats.Name = "leaderstats"
local coins = Instance.new("IntValue",stats)
coins.Name = "Coins"
end)
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("CoinSaveSystem")
game.Players.PlayerAdded:connect(function(player)
local stats = Instance.new("Folder",player)
stats.Name = "leaderstats"
local coins = Instance.new("IntValue",stats)
coins.Name = "coins"
coins.Value = ds:GetAsync(player.UserId) or 0
ds:SetAsync(player.UserId, coins.Value)
coins.Changed:connect(function()
ds:SetAsync(player.UserId, coins.Value)
end)
end)
game.Players.PlayerRemoving:connect(function(player)
ds:SetAsync(player.UserId, player.leaderstats.coins.Value)
end)

3 comments
Need more info on what you mean by "it wont save". Do you mean that the value is created but left with a nil value, or just that it's creating two datastore values?
I mean for example if I got 50 coins and leave when I come back it is back to zero coins
there are always two lederststs