How to make a cube move up, then down on it's owne?

Okay in detail, i’m making a 3D game. And I need an object to move up, then back down again, so the player can hop on then go up. Though I can’t find a way to do it, any help?

PS C# only : )

public float frequency = 1f; //movement speed
public float amplitude = 1f; //movement amount

Vector3 startPos;
float elapsedTime = 0f;

// Use this for initialization
void Start () {
    startPos = transform.position;
}

// Update is called once per frame
void Update () {
    elapsedTime += Time.deltaTime * Time.timeScale * frequency;
    transform.position = startPos + Vector3.up * Mathf.Sin(elapsedTime) * amplitude;
}