Teleport script

Hello I need help with this code, I’m trying to get the player to move a set distance forward when I press Q but right now its pretty inconsistent, when I press Q, it will somtimes go straight forward and other times start making me go right or left randomly.

    private void Teleport()
    {
        //if the q key is pressed
        //move the transform forward
        if (Input.GetKeyDown(KeyCode.Q))
        {
            transform.position = transform.position + new Vector3(transform.position.x, 2, 0);
            Debug.Log("QQQQQ");
        }
    }

if you want to move 2 meters forward (at viewing direction)

transform.position += transform.forward * 2;

*works if players Z blue axis is forward, if not, use the others: .right, .up, …

if want to move in worldspace,