How do I go about making a script where I can select an object from an array to be set active based on a value, and when that object is set as active than everything else in the array is unactive?

If I have a float called object value, that can be changed or assigned through any script and I have an object array, and I want to select an object from the “object array” in relation to the object value.

    public float objectVal;
    public GameObject[] Object;

I want to select or reference

object[0] when objectVal = 0 and object[1] when objectVal = 1, etc.

And after a certain object is selected / referenced, I want to set that object active, while disabling every other object that is not referenced in the “object array”

I know my newbie skills are extremely visible in my question, but I do know some of the terminology and code to use, I just don’t know how to structure and format the code to where it can do what I’m trying to do.

Here is an example. The randomVal can be used however you want. Since no context was given on how you plan on setting/“selecting” the value, I just did a Random.Range to get the point across:

public class Stuff : MonoBehaviour
    [SerializeField] private GameObject[] objects;
    private void Start()
        var randomVal = Random.Range(0, objects.Length);
        for(var i = 0; i < objects.Length; i++)
             objects*.SetActive((i == randomVal) ? true : false);*