Spawning weapons in Player's hand.

Hi Guys i am trying to create first person Multiplayer game, and i have really big problem with weapons spawning in players hand, becouse when i put on my weapon, it is spawning only in first connected to server player.
My code looks like this:

if (Axe is dressed)
{
SpawnAxe();
}
@RPC
function Spawn Axe ()
{
Spawner.Axe=true;
}

And in the spawner script:

if (Axe==true)
{
var object = Network.Instantiate(AxePrefab, gameObject.transform.position, gameObject.transform.rotation, 0);
object.transform.parent = gameObject.transform;
}

Spawner script is in the hand of all players, and when Axe==true it spawning axe, but it spawning in random player
why???

If I’m not mistaken, you call RPCs with a photonview. The axe is likely not spawning randomly, but only in the player who called the method explicitly. Just use GetComponent to get the photon view, and then call photonViewComponent.RPC(“SpawnAxe”, PhotonTargets.All). Check out the documentation for the RPCs so you can get player ID and all that for keeping track of who made the call.

I am not using photon Networking, but thanks for answer, i think finding Players ID is good idea, I’ll try it

Oh my bad. I assumed everyone just used photon considering Unity’s built in networking isn’t very good. Hope you got it working. :slight_smile:

I don’t like photon becouse it make me i feel limited in what i do, and yes it is finally working, thanks for your advice ^^