Find gameobject by Networkplayer?

On the server side of my game I have a player.cs script attached to every playerprefab on the scene. What I need is to get the player script on the gameobject owned by a specific networkplayer.

The reason I’m using networkplayer is because this happens OnPlayerDisconnected(NetworkPlayer)

So how am I supposed to do this? Oh and one more lil thing, are viewIDs unique per player or per gameobject? If one player owns two gameobjects, do they have same viewID?

Actually, disregard my last answer, what is much eaiser is to just associate the Networkplayer with a player gameobject when they connect to the server,

OnPlayerConnected(Networkplayer playerNP){
  // here you instantiate your player right? Add them to a List and add the networkplayer to a list as well, that way the int ids both

Then you just get the int on disconnect with

int disconnectedPlayerID = NetworkPlayerList.IndexOf(NetworkPlayerDisconnecting);


viewId’s are unique to the object but should match across all clients. That viewID is owned by the NetworkPlayer that created it (or re-set it’s ID) but it’s best to have all viewID’s owned by the server and have the clients just know what objects they are allowed to control, Here’s a tutorial that might help: