PlayerRemoving sometimes doesn't fire

I had a huge issue in my game ([URGENT] Plots not destroying - #10 by coolgueo), and eventually I fixed it by changing “PlayerRemoving” to “ChildRemoving”. PlayerRemoving sometimes does not fire which caused “ghost bases” in my game.

Expected behavior

PlayerRemoving to always fire.

Hello There! I hope you’re doing well.
Thank you for taking the time to submit this issue and for reading our message.

To help us move forward, we’d appreciate your support with a few questions:

  • Is this issue still occurring on your device?

  • If so, could you please send us a log?

Don’t worry — we’ve got you covered!
You can find step-by-step instructions on how to generate and send the log How to post a Bug Report - Bug Reports - Developer Forum | Roblox

Following these steps will help us better understand the issue and work on a solution more efficiently.

Thank you again for your cooperation!

Thanks for responding. It still occurs, but I’m confused on why you’d need a log because it is a server event.
I don’t have any specific date and time this happens as it occurs randomly.

In Workspace, does SignalBehavior say Default or Deferred?

image

Interesting, I was actually thinking that it could have been set to Deferred.

If you set it to Immediate does it still happen?

Well I’m not sure,

as like I’ve said it’s random. I’ll set it to immediate and join servers in an hour or so to see if there’s any ghost bases.

Try that, as it will help to figure out if the issue is caused by the SignalBehavior or not.

It’s possible that if you switch from Immediate, that you may run into Errors that would have eventually not been found while it was set to Deferred ? :thinking:

1 Like

It still occurs. I’m sure this isn’t a problem with my code though..

How do you know that it still occurs? Is it on a live server?

Because I can join a server and there’s a plot for someone who isn’t in the server

If you go here https://create.roblox.com/dashboard/creations/experiences/1/analytics/errors?rangeType=Last28Days

But change it to your game since the link at the top has it set to 1. Do you see any errors by chance?

This is a useful page, and an alternative over debugging with webhooks for capturing logs from the Client and Server, that occured on a Live Server.

 

If you don’t see anything, try to put a warn("test") or similar right at the start of the callback for all .PlayerRemoving you can find, and let it run for a bit. But since you said that some do run and some do not, try to put more of these around the code maybe there’s a step that isn’t working as expected? At least, you should verify that.

And or then you can check it in the console in-game, you don’t even need to use the analytics. Unless you’re already doing that?

Players.PlayerRemoving:Connect(function(player: Player)
	warn(`PlayerRemoving: {player.Name}`)
        -- rest of code...
 	warn(`END - PlayerRemoving: {player.Name}`)
end)

 

If the player’s base didn’t get removed, do you by chance see the name of the player who’s base didn’t get removed. If yes, you could eventually add the player’s name into the warning, at each place as well to debug.

Point is to get evidence and confirm that it actually doesn’t get called, by doing it like this. I think it takes a little bit time for fresh logs to show up in the analytics.

Also, something like this?:

Players.ChildRemoved:Connect(function(player: Player)
	local plot = Plots[player.UserId]
	warn(`{player.Name} is leaving`)
	if plot then
		plot:Destroy()
		
		Plots[player.UserId] = nil
	else
		warn(`No plot found for player {player.Name}`)
	end
	
	SessionData[player.UserId] = nil
	warn(`{player.Name} left`)
end)

Setting it to immediate seems to have made it more frequent from what I’ve seen also

Yes, and then when you join in-game you should be able to see these warnings in the console to verify whether it ever went through the entire function or not.