DataStoreService not working when player leaves?
Trying to store data with DataStoreService
when player leaves the game and its not working.. Here is the code for the values ( They are the same for each one just different values ) :
1 | local PlayerNo = Instance.new( "IntValue" ,folder) |
2 | PlayerNo.Name = "PlayerNumber" |
3 | PlayerNo.Value = PNo:GetAsync(player.UserId) or 11 |
4 | PNo:SetAsync(player.UserId, PlayerNo.Value) |
and here is when players leave function:
1 | game.Players.PlayerRemoving:Connect( function (player) |
2 | PN:SetAsync(player.UserId, player.PlayerName.PlayerN.Value) |
3 | PNo:SetAsync(player.UserId, player.PlayerName.PlayerNo.Value) |
4 | Pos:SetAsync(player.UserId, player.PlayerName.PlayerPos.Value) |
5 | Lang:SetAsync(player.UserId, player.PlayerName.PlayerLang.Value) |