Get speed variable from another script c#

I have two scripts, one in which there is a variable called “speed” that is increasing over time, and another script that moves the gameobject, i am wondering if it is possible to get the “speed” from one script and access it in the movement script.

Speed script:

using UnityEngine;
using System.Collections;

public class SpeedUp : MonoBehaviour {

	public float speed;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	public void Update () {

		speed += 0.005f * Time.deltaTime;

	}
}

Movement script:

using UnityEngine;
using System.Collections;

public class ObstacleMove: MonoBehaviour {
	
	private Vector3 reset;

	public float move = 170.0f;
	
	void Start () {
		
	}
	
	void Update () {
		
		Vector3 Trans = Vector3.left * move * Time.deltaTime;
		transform.Translate (Trans);
		
		if (transform.position.x < -300) {
			
			Destroy(gameObject);
		}
		
	}
}

I have looked into GetComponent but im not really sure how to use it in this case, would it be possible to get the increasing speed from the speed script to the movement script, so that the movement would be increasing speed over time? Sorry if it sounds confusing :slight_smile:

As a concrete example, if SpeedUp and ObstacleMove are attached to the same gameObject then, in ObstacleMove, use the line

float speed=gameObject.GetComponent<SpeedUp>().speed 

For instance try adding the following to after line 16 to ObstacleMove

SpeedUp speedUp=gameObject.GetComponent<SpeedUp>();
if(speedUp!=null){
    Trans=Trans+speedUp.speed*Time.deltaTime*Vector3.left;
}