I'm sorry, I use Google translator!
local DataStore = game:GetService("DataStoreService"):GetDataStore("PlayerStats")
game.Players.PlayerAdded:connect(function(player)
local playerKey = "user_" .. player.userId
local leaderstats = Instance.new("Model")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Wins = Instance.new("IntValue")
Wins.Name = "Wins"
Wins.Value = DataStore:GetAsync(playerKey)
Wins.Parent = leaderstats
print(playerKey)
while wait(5) do
for _, player in ipairs(game.Players:GetPlayers()) do
if player:FindFirstChild("leaderstats") then
player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
DataStore:SetAsync(playerKey, Wins)
end
end
end
end)
if you remove the "DataStore: GetAsync (playKey)", the leaderboard will show Wins, but will not save
But if you leave this line, it will not save, as well as leaderboard will not show Wins

1 comment
You're saving the last created Wins instance, not the Value of the current player's Wins. This is all wrong.