Okay, so this is basically what I do:
When a player joins, this runs.
if not data:GetAsync(player.userId.."Wins") then print(data:GetAsync(player.userId.."Wins")) data:SetAsync(player.userId.."Wins",0) end wins.Value=data:GetAsync(player.userId.."Wins") print("Wins: "..data:GetAsync(player.userId.."Wins"))
The output, on the first time joining is:
0, Wins: 0
The output on the second time joining is:
Wins: 0
When a player wins a game, this runs (in a generic for loop):
winskey = data:GetAsync(v.userId.."Wins") data:IncrementAsync(winskey, 1) wins = game.ServerStorage.PlayerStats[v.Name].Stats.Wins wins.Value = wins.Value + 1 print(v.Name.."'s wins: "..data:GetAsync(v.userId.."Win"))
The output here is really weird. First time of winning:
player's wins: 1
Second time of winning:
player's wins: 0
Third:
player's wins: 3
Fourth:
player's wins: 0
5th:
player's wins: 5
It was suggested to me to change the key to "Win" instead of "Wins," and this is what the output was on the first time:
player's wins: 0
Second:
player's wins: 2
Third:
player's wins: 0
4th:
player's wins: 4
etc.
Does anyone know what my problem is, and how to fix it? I've asked several people and can't figure it out. If you need any more info, please let me know.
--MightyWanderer
(Also, as a note, there's no selection for "Data Stores" in the tags, which would be nice to have.)
Here you are assigning a number to winskey:
winskey = data:GetAsync(v.userId.."Wins")
Here you are using that number as the key to increment:
data:IncrementAsync(winskey, 1)
I believe your intent is to set winskey like this:
winskey = v.userId.."Wins"
Good luck!