Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

DataStoreService not working when player leaves?

Asked by 6 years ago

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 ) :

1local PlayerNo = Instance.new("IntValue",folder)
2PlayerNo.Name = "PlayerNumber"
3PlayerNo.Value = PNo:GetAsync(player.UserId) or 11 -- 11 is just default if the player has no stored number
4PNo:SetAsync(player.UserId, PlayerNo.Value)

and here is when players leave function:

1game.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)
6end)
0
When the server shuts down PlayerRemoving will not fire so you also need to save data on BindToClose User#5423 17 — 6y
0
Still not working budd. vBaRaAx02 1 — 6y

Answer this question