Question about lag, disconecction and PlayerRemoving

Hello, I have a question: If a player is disconnected due to internet problems and reconnects without exiting the game, PlayerRemoving will be fired?

4 Likes

Yes, when a player is removed from a game in any way at all, PlayerRemoving fires.

Even when booted because of the internet, being kicked, or leaving by their own choice.

See more:
PlayerRemoving
CharacterRemoving

Yes. PlayerRemoving will fire no matter what happens when a player leaves. Kicking, internet, etc

1 Like

Yes, it will fire. However if the server shutdowns, PlayerRemoving may not have a chance to fire.

Agreed. In order to fix this, a BindToClose function is recommended.

Edit - Only for saving data

Yes, however in rare cases if that doesn’t fire, you would have to implement auto-saving.

When a player leaves I delete his folder so if he come back to the same server, his new folder is gonna be generated and the former won’t interfere. If the player is disconnected and he press Reconect or whatever this will fire and the playerAdded to?

game.Players.PlayerRemoving:Connect(function(player)

	wait(2)
	
	game.ServerStorage[player.Name]:Destroy()
	
	
end)

No it will not be fired. Here is some example scripts
This first one will be required:

game.Players.PlayerAdded:Connect(function(plr) -- The plr is specifying the Player. 
-- Whatever you want to happen here
end)

and to do PlayerRemoving

game.Players.PlayerRemoving:Connect(function(plr)
-- What I think you are doing is datastores, so here you go. Make sure your Datastores are already specified
local datastore = key --Change key to what you did in local ds = DataStore:GetDataStore("Whatever, reset this, reset all data")
local data = plr.leaderstats.Money.Value -- This is if your currency is Money. If it is in a folder called Data, and a currency called Coins, do this: plr.Data.Coins.Value

datastore:SetAsync(data)

If you need more help, feel free to message me on the DevForum, but please read this first. This has all the info on how to add PlayerRemoving:

I’ve tested it, and yes, PlayerRemoving will be fired.