How to make my sprite stay in the same x coordination

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Playerscript : MonoBehaviour
{
    // Start is called before the first frame update
    private float speed = 5f;
    public Animator animator;
    void Start()
    {
        animator = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    { // kiểm tra người chơi có đụng tường không.
     
        if (Input.GetKey(KeyCode.LeftArrow))
        {
            this.transform.Translate(Vector3.left * speed * Time.deltaTime);
            this.transform.rotation = Quaternion.Euler(0f, -15f, 0f);
        }
        else if (Input.GetKey(KeyCode.RightArrow))
        {
            this.transform.Translate(Vector3.right * speed * Time.deltaTime);
            this.transform.rotation = Quaternion.Euler(0f, 15f, 0f);
        }
        else
        {
            this.transform.rotation = Quaternion.identity;
        }

        
    }
    private void OnCollisionEnter(Collision others)
    {
        if (others.gameObject.CompareTag("Bonked"))
        {   
            animator.SetTrigger("Fall Flat");
            animator.Play("Fall Flat");
        }
    }
}

When I use this code, the player move backwards in x direction.

Hi, I think that if you want some help it would be helpful to give a little more explanation about your problem :wink: Maybe images or videos to better see the issue.

You say Sprite in the title, is it a 2D game ? So why apply a rotation of 15deg ?

Note that transform.Translate without specifying the second argument apply the movement in local space.

It is a 3d endless runner game, when turn left, I want my sprite turn 15 degrees to the direction to the left and the right but suddenly it went backwards which is not intended.