How can I make my truck drive on terrain and on bridge

I have my game set up to where if the player is driving and loses contact with the terrain, he loses control of the vehicle. Basically the logic is that all user input code is wrapped in an if statement checking if groundContact is true. OnCollisionEnter, if the object you’re colliding with equals “Terrain,” groundContact is true. OnCollisionExit, if the object you WERE colliding with equals “Terrain,” groundContact is false. I tried making it like this instead:

function OnCollisionEnter(grounder : Collision){
    if(grounder.gameObject.name == "Terrain" || grounder.gameObject.name == "Bridge"){
        groundContact = true;
    }
}

function OnCollisionExit(grounder : Collision){
    if(grounder.gameObject.name == "Terrain" || grounder.gameObject.name == "Bridge"){
        groundContact = false;
    }
}

I even tried checking both of them at the same time by a user defined tag and set both the bridges and the terrain to said tag. I know it’s that OnCollisionExit thats breaking it. The player transitions onto the bridge from the Terrain without ever leaving the ground, but since it exits the collision with Terrain, it sets groundContact to false while you’re also colliding with Bridge. Any ideas?

I wouldn’t use the name.
It’s better to use Tags.
That’s how you define Tags : Unity - Manual: Tags

Your script would look like this (if you tag your Terrain and Bridge ground):

    function OnCollisionEnter(grounder : Collision){
    if(grounder.gameObject.tag == "ground"){
    groundContact = true;
    }
    }
     
    function OnCollisionExit(grounder : Collision){
    if(grounder.gameObject.tag == "ground"){
    groundContact = false;
    }
    }