What I want to do is make it so when a my player collides with anything the value of a variable will change. How do I do that?
Use the code provided by @andrew-lukasik if yout collider is not marked as trigger. If you need to use a trigger, you must use the OnTriggerEnter
family functions.
Also make sure to have a rigidbody in the same object as the collider.
I recommend you to check for documentation, Unity - Scripting API: Collider and read it, don’t worry if do not understand everything, just read it and will discover things for sure.
Good luck!
public int counter = 0;
void OnCollisionEnter(Collision collision)
{
counter = counter + 1;
// shorter forms of the same:
// counter += 1;
// counter++;
}