Help with high level multiplayer

Godot Version

v4.4.1.stable.official

Question

DISCLAIMER!!!
I am really new Godot so some things might be wrong or weird due to that.

Hello! I am trying to implement multiplayer in LAN for a larger group project but I need to figure out how it works and how to do it first. I have a problem with player spawning and I truly have no idea how to fix it.
Right now one of the instances of the game has to host the server specifically as I could not figure out how to make the host play alongside the rest of the players. Still, if a player joins the server, server side another copy of the player (as seen in the remote scene tree) spawns, that no client has authority over and, on the client side, I can’t interact nor see the instance. If I disconnect as the host aka (I suppose) close the server, the client instance (the real controllable one) doesn’t get despawned even though I accounted specifically for the case where the host disconnects (probably just bad implementation but, again, I can’t manage to see why). If I host again on the same instance that hosted previously the “ghost” that remained cannot be seen or interacted with by the clients that connect, but the previous extra instance of the player that got spawned can now both be seen and interacted with by the client but again no client has authority over it.






Unfortunately I cannot upload the project itself so I provided photos of my code and if anyone sees this and needs more screenshots of any other things I will upload them.

Seems like the network_handler might be important, the rest of this code does look fairly standard


Please paste code instead of screenshots