Collection Using "GetComponent"

I am trying to create a script that allows the player to collect power ups. When the player collides with this powerup, I want a variable on a script attached to the powerup to turn to true (“Collected”). The rest of the code works fine, but on the “GetComponent” line I get the error is “The best overloaded method match for “UnityEngine.GetComponent(System.Type)” has some invalid arguments”. Anyone know what this means and how to fix it? Thank you in advance!

void OnTriggerEnter (Collider hit)
        {
        if(hit.gameObject.tag == "Weapon")
        {
        if(Inventory.Instance.HCisUnlocked == false)
             {
             Inventory.Instance.HCisUnlocked = true;
             //Turn off the Collider
             hit.collider.GetComponent(TheScript).Collected = true;
             Debug.Log("Collected PowerUp");
             }
        if(Inventory.Instance.HCisUnlocked == true)
             {
             WeaponStates.Instance.HC.Ammo += AmmoBoost;
             hit.collider.GetComponent(TheScript).Collected = true;
             }
        }
        }

To use GetComponent in C# is a bit different than JS. For one, variables are private by default in C#, so you need to make Collected a public bool in your other script.

public bool Collected;

To access it from your other script, a minor difference from what you had:

hit.collider.GetComponent<TheScript>().Collected = true;