Variable changing value randomly

I’m making a script for this blimp to slowly go up and down in the background. I assign its max height and min height in the Start() method. The script doesn’t work right. When I print the variables using Debug.Log(), I can see the max and min height variables changing values even though they are not being assigned in the Update function. Here is the code:

// Use this for initialization
	void Start () 
    {
        // Height variation = 50
        // transform.position = -10, 100, 192
        maxPos = transform.position + new Vector3(0, 0, heightVariation);
        minPos = transform.position - new Vector3(0, 0, -heightVariation);
        destination = maxPos;
        speed /= 100;
	}
	
	// Update is called once per frame
	void Update () 
    {
        Debug.Log("Max: " + maxPos);
        Debug.Log("Min: " + minPos);
        if (goingUp)
        {
            transform.Translate(0, 0, speed);
            if (Mathf.Abs(Vector3.Distance(transform.position, maxPos)) < speed/2)
            {
                goingUp = false;
                transform.Translate(0, 0, -speed);
            }
        }
        else
        {
            transform.Translate(0, 0, -speed);
            if (Mathf.Abs(Vector3.Distance(transform.position, minPos)) < speed / 2)
            {
                goingUp = true;
                transform.Translate(0, 0, speed);
            }
        }
	}

This picture shows what I mean. The values of Max and Min change between 217 and 242.
37285-1.png

I’m not sure what’s going on here. Any help would be appreciated. Thanks!

Variables never change by themselves under any circumstances; they can only change if you caused them to do so in some way. I would assume you have the script attached to more than one object, with different values on the scripts. If you use Debug.Log("Max: " + maxPos, gameObject), then you can click on the output in the console, and it will highlight the object in the hierarchy that printed that line.