Assigning a value to a variable using another variable?

Trying to create my first movement script by myself, and I’m attempting to assign the value from the variable ‘maxspeed’ to the variable ‘speed’, but my script just doesn’t work. I simply assigned ‘maxspeed’ as a public float and gave it the value ‘25’, then replaced every instance of ‘25’ in my code with ‘maxspeed’.
Here’s my newb noob code:

{
	public float speed;
	public float maxspeed = 25f;
	public string MoveUp = "e";
	public string MoveLeft = "s";
	public string MoveDown = "d";
	public string MoveRight = "f";
	void Update()
	{
		if (Input.GetKey(MoveUp))
		{
			speed = maxspeed;
			transform.Translate(0, 0, speed * Time.deltaTime);
		}
		if (Input.GetKey(MoveLeft))
		{
			speed = maxspeed;
			transform.Translate(speed * Time.deltaTime, 0, 0);
		}
		if (Input.GetKey(MoveDown))
		{
			speed = maxspeed;
			transform.Translate(0, 0, -speed * Time.deltaTime);
		}
		if (Input.GetKey(MoveRight))
		{
			speed = maxspeed;
			transform.Translate(-speed * Time.deltaTime, 0, 0);
		}
		speed -= 0.05f;
		if (speed < 0)
		{
			speed = 0;
		}
	}
}

You want the player to keep moving a bit after the buttons are released? It seems you are attempting to incorporate a deceleration but you made a mistake.

You only translate while a button is currently down and every frame where any button is down the speed variable gets set back to 25. It will always move at speed 25 and only if a button is down.

You need to add translation anytime is speed is greater than 0. Maybe you want to store the direction vector anytime a button is pushed so that the deceleration is in the right direction of the last button pushed.