Is there a way to detect if a player has crashed?

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?

4 Likes

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.

3 Likes

The server is fine whenever the creation is saved.
It only crashes once a player which crashed leaves the game.

1 Like

Then I recommend trying that ping system.

1 Like

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.

1 Like

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.

1 Like

Should i use a remote event for this, Or should i use a remotefunction?

1 Like

Surely you can use PlayerRemoving which fires when the player leaves a game, since technically if the player crashes they do leave the game.

1 Like

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

1 Like

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.

1 Like

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.

1 Like

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.

1 Like

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.

1 Like

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.

1 Like

Does the event fire on the crashed client?

1 Like

Yes the network owner is set correctly, I have checked it with the showowners option in the settings.

1 Like

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.

1 Like

But the server crashes before the playerremoving event could be fired.

1 Like

Wait… The server is crashing as well? What is making the server crash?

EDIT: Yes, sorry I read wrong

1 Like

I have no idea, But about 2/3 seconds after the crashed player leaves the game, The server freezes.

1 Like