TargetRpc from non player object with authority

I have an object that has authority set on it to the client that is interacting with it. The object requests some information from the server(Command) and I would like this information sent back via a TargetRpc so it doesn’t send the information to all clients.

The problem is that TargetRpc requires a NetworkConnection as a parameter and on the object on the server connectionToClient is null. How do I get the right NetworkConnection to send the TargetRpc to the right client?

I asked a similar question recently in the below thread, but haven’t had a chance yet to try out the solution.

Yeah I have that working just not for an object that isn’t a player, but a player has authority over it. If I do it in the player everything works great. I do it on an object that isn’t the player and connectionToClient is null.

After having some time to think about how this works, I have concluded that I don’t want the client to have authority over the object.

I originally wanted to “block” other players from having access to the object when it was already being accessed, so I thought having authority would do that. Turns out that when a client gets disconnected any object they have authority over gets removed. This is not a good thing to happen to the object that they are accessing.

My plan is to setup a SyncVar bool and have it set to true if someone is accessing the object. Then when someone else tries to access it they check the bool on their end and if false, they can access it.

If there is some way to stop it from despawning the object when the owner disconnects, it would be nice to know, and how to send TargetRpc’s on a non player object.