Third Person Controller Issue,Third Person Controller

So I am making a third person shooter/royale game, and I am using this free asset from the store that is a third person controller that alloows sprinting walking and jumping and camera moving action. I created this script in C Sharp the other day and implemented it too the third person controller. The script is based on weapon picking up, after implementing the script into the third person controller, it worked and all it’s just the weapon floats around the third person controller as if it were orbiting it. I need the weapon to stay in the third person controllers hands. It would be great if a user can reply and help me, maybe it’s my code, idk just please help.

Heres the code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WeaponPickUp : MonoBehaviour {

    public GameObject M4A1;
    public GameObject M4A1Ground;

	void Start () {
        M4A1.SetActive(false);
	}

    void OnTriggerEnter(Collider _collider)
    {
        if(_collider.gameObject.tag == "Player")
        {
            M4A1.SetActive(true);
            M4A1Ground.SetActive(false);
        }
    }
}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WeaponPickUp : MonoBehaviour {

    public GameObject M4A1;
    public GameObject M4A1Ground;

    void Start () {
        M4A1.SetActive(false);
    }

    void OnTriggerEnter(Collider _collider)
    {
        GameObject obj = _collider.gameObject;
        if(obj.tag == "Player")
        {
            M4A1.SetActive(true);
            M4A1Ground.SetActive(false);

            Transform tf = obj.transform;
            M4A1.transform.position = tf.position +
                tf.right   * gunPosition.x +
                tf.up      * gunPosition.y +
                tf.forward * gunPosition.z ;

            M4A1.transform.parent = tf;
        }
    }
}

Set gunPosition equal to a Vector3 hat defines the offset from the player to the gun and this should world, you’ll need to experiment with the positions, but the use of the forward, right and up properties of the transform means those locations will always be relative to the direction. The position is set before parenting so that the offset is maintained after moving and rotating.