The float gives 0 although it is assigned

This is my script to move game objects along the x axis.

public class MoveObjects : MonoBehaviour
{
    public static float speed;
    private void Start()
    {
        speed = 7.5f;
    }

    private void Update()
    {
            this.transform.Translate(new Vector3(-speed * Time.deltaTime, 0, 0));
            speed += Time.deltaTime * 0.1f;
    }
}

When I called the speed variable outside of the class it gives me 0. That does not make sense. I could not find any solutions. What could be the problem? Thank you for your time.
Note: I debugged like

Debug.Log(MoveObjects.speed);
Debug.Log(MoveObjects.speed*Time.deltaTime);

Hey there,

the issue is that you access the variable by class type and not by instance.
So if you write Debug.Log(speed); in your Update function of MoveObjects you will get the right value.

You should read into the differences between classes/types and instances. In other words MoveObjects.XY != GetComponent<MoveObjects>().XY

Hope this helps. Let me know if you need further clarification.

asign speed on setup to a managerscript

like this for example:

public float speed = 7.5f;

ManagerScript ms;

void Start (){
  ms = Camera.main.GetComponent<ManagerScript>();
  }
void Update(){
  speed = ms.speed;
  }