How to Make a RigidBody not accelerate?

I’m trying to make a moving platform that slides up and down. I’m new to Unity so this might not be the best way to do this. I need to make the platform not eccelerate so it doesn’t fly off the screen. Does anyone know a better way to do this or a way to stop acceleration?

Here is my Code:

using UnityEngine;

public class MovingPlatforms : MonoBehaviour
{
    private Vector3 lowestPos;
 
 

    private void Start()
    {
        lowestPos = transform.position;
    }


    private void Update()
    {
     
        if (transform.position.y >= lowestPos.y + 3)
        {
            GetComponent<Rigidbody2D>().gravityScale = 1;
        }
        if (transform.position.y <= lowestPos.y)
        {
            GetComponent<Rigidbody2D>().gravityScale = -1;
        }

    }



}

I realized that this plan wouldn’t work and that when another Rigidbody lands on top, It falls down due to the gravity increase. So instead of using gravity does anyone have a better way of doing this?