Godot Version
4.6
Question
I’m trying to figure out how to delete a player when the window gets closed without making a custom window border. In my game since its multiplayer the only time the game deletes a player is when the game is exited using the “esc“ key, but when you exit the window it keeps the player there, I tried making a "timeout timer” but that doesn’t work.
if Input.is_action_just_pressed("esc"):
$"../".exit_game(name.to_int())
get_tree().quit()
Thanks in advance 
You can try to either put the logic in “exit_tree” or you can look into notifications!
2 Likes
I found a solution using this doc, instead of putting the code into the _exit_tree() function I put it into a _notification() function and made sure to check if it was multiplayer authority otherwise it would close the server on both ends:
func _notification(what: int) -> void:
if !is_multiplayer_authority():
return
if what == NOTIFICATION_WM_CLOSE_REQUEST:
$"../".exit_game(name.to_int())
1 Like
So you essentially did what I suggested and marked your own message as a solution, cool!
3 Likes
My bad I thought I put this doc in as a reference on my reply.