Changing Weapon Position Via Script

Hey So I’m having an issue with this. I’m trying to change my gun position when the player runs.
I made a little script to start doing this but not sure how to implement it so the changes to the position I want and moves with the parent “player” object? Currently if i try and change the gun position to something else, when I start moving the gun ends up in a weird position behind the player. I move the gun while the game is running, get the positions, then try and add them to the script

public class GunPosition : MonoBehaviour
{
    //weapon object
    public GameObject gameObj;

    //Attaching playermovement script to use it's varables
    public playermovement Player;


    // Start is called before the first frame update
    void Start()
    {
        //weapon start position
        gameObj.transform.position = new Vector3(0.1349f, 0.1358f, 0.3093f);
        transform.localPosition = new Vector3(0.1349f, 0.1358f, 0.3093f);
    }

    // Update is called once per frame
    void Update()
    {
        if (Player.moveDirection != Vector3.zero) //when player is moving, change gun position
        {
            //Example
            gameObj.transform.position = new Vector3(1.0f, 1.0f, 1.0f);
            transform.localPosition = new Vector3(0.1349f, 0.1358f, 0.3093f);
        }

    }
}

I can’t even understand what the problem is… can you post some screenshots? Preferably what it looks like before and after, and maybe a pointer to where you want the gun to actually be.

From what it sounds like, your gun is probably parented to something you don’t want it to. You should just switch that to match where you want your gun’s new placement to be.

Hey yeah the gun is parented to the player

Solved the issue using Rig Layers