I have noticed players can crash the server by crashing themselves and i have no idea what is causing this.
The only way i can prevent the servers from crashing is by removing the creation before they leave the game after the crash, But for that i will need a way to detect if a player has crashed.
Is there a way to detect if a player crashed on the server side?
Try using a ping check system. If the ping was too high when the player left, break the function. As well as that, if your game is crashing when saving these creations, try using a system of pcall(function()'s to order it without crashing the server.
Im not really sure if the ping system is the solution for me.
Some people could get a high ping once a creation is being spawned in, Which will cause some issues for them.
Also fair. In direct answer to your question, there is no direct way, by my knowledge, to determine if a player has crashed as a crash is the client-server connection being severed suddenly. Therefore, the server would not know if the client has crashed directly, but rather through indirect means.
If you used a remote function, you might be able to add a timeout and then sever the connection if the timeout reaches a certain limit (your ping limit).
Sounds like something else is causing the server crashes, check how you’re removing their creation and consider adding yields in the removal function, this could be what is causing crashes.Have you also considered that the player who crashes initially may have done so because of a server side problem? Perhaps it is not the first crash causing the issue, but one server side issue that is causing multiple players to crash.
Try destroying the parts slowly, not all at once. The image shows a good deal of individual parts with motors attached, so that is likely you’re peoblem. Delete the parts by a x amount, then wait. That way, you won’t cause lag by deleting parts.
I have tried removing the removal function and removing the creation in pieces, But none of those worked.
I did notice the server is fine whenever i delete the creation before the crashed player leaves the game.
And the server does not crash when a crashed player without a creation leaves the game.
The playerremoving event does not fire whenever the crashed player is about to leave the game.
Detecting if a player has crashed seems like treating a symptom. Do you set network owner of the creation to the player explicitly? When they leave perhaps the owner is reset to the server and everything immediately crashes because the server is now trying to simulate all of those parts.
Why don’t you have a remote event which fires when a player is about to leave?
Then, write an event handler on the server which waits for the player to leave. If they leave and you have received a remote event signaling that the player leaving was intentional, you assume they left normally. If you didn’t, you could safely assume that they crashed, as a player removing function can’t fire for a crashed client, for obvious reasons.
It shouldn’t. If a player crashes, the usual tear down procedures (ending connection, firing events, etc.) shouldn’t happen because the client has terminated abnormally. In many cases, the code for the game client actually looses control at that point.
However, the server sees that that client is no longer connected and fires an event for it. So, the server event should still fire.