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

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

and here is when players leave function:

game.Players.PlayerRemoving:Connect(function(player)
 PN:SetAsync(player.UserId, player.PlayerName.PlayerN.Value)
 PNo:SetAsync(player.UserId, player.PlayerName.PlayerNo.Value)
 Pos:SetAsync(player.UserId, player.PlayerName.PlayerPos.Value)
 Lang:SetAsync(player.UserId, player.PlayerName.PlayerLang.Value)
end)
0
When the server shuts down PlayerRemoving will not fire so you also need to save data on BindToClose User#5423 17 — 5y
0
Still not working budd. vBaRaAx02 1 — 5y

Answer this question