Give instantiated object same transform as localPlayer.

Hello,
I have a problem, i can’t seem to find a solution on how to instantiate an object and then “attach” it to the localPlayer.
It works only on host, on clients the object stays at the instantiated position.
I’m kinda new to Unity Networking, please help me!
Here is my code, based on unity’s tutorial.

using UnityEngine;
using UnityEngine.Networking;

public class PlayerController : NetworkBehaviour
{
    
    public GameObject something;
    public GameObject theItem;
    public Transform player;
    
    void Update()
    {
        if (!isLocalPlayer)
        {
         return;
        }
        
        var x = Input.GetAxis("Horizontal") * Time.deltaTime * 150.0f;
        var z = Input.GetAxis("Vertical") * Time.deltaTime * 3.0f;

        transform.Rotate(0, x, 0);
        transform.Translate(0, 0, z);
        
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Destroy(theItem);
            CmdFire();
        }
        theItem.transform.position = player.position;
    }

[Command]
void CmdFire()
{
        theItem = (GameObject)Instantiate (
        something,
        player.position,
        player.rotation);
        
         NetworkServer.Spawn(theItem);
}
}

Thank you so much for your time!

Try this.
Set the object’s parent to the player and it should stay with the player.
You can make a script on the object’s Awake() function so when it spawns it dose this on the server and clients.

Hope this helps.