I have problems with my enemy AI script.

my enemy dosent turn but i made his script and put the triggers so that he turns.

Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyIA : MonoBehaviour
// his name is Mr. Enemy
{

public float speed;
public bool MoveRight;

// Update is called once per frame
void Update()
{
    // if move right bool is true mean he is will move to the right
    if (MoveRight)
    { 
        transform.Translate(2 * Time.deltaTime * speed , 0,0);
        transform.localScale= new Vector2 (1,1);
    }
    else 
    {
          transform.Translate(-2 * Time.deltaTime * speed , 0,0);
          transform.localScale= new Vector2 (-1,1);
    }
}

void OntriggerEnter2D(Collider2D trig)
{
if(trig.gameObject.CompareTag(“turn”))
{
if(MoveRight)
{
MoveRight = false;
}
else
{
MoveRight = true;
}
}
}
}

transform.localScale= new Vector2 (1,1);

    and
    
    transform.localScale= new Vector2 (-1,1);
    
    This is to resize the object which is not needed, looks like your trying to force it left by resizing it left.
    
    With the transform.Translate(2 * Time.deltaTime * speed , 0,0);
    
    try
    
    transform.Translate(Vector3.right * Time.deltaTime * speed);
    
    and
    
    transform.Translate(Vector3.left * Time.deltaTime * speed);

it still dosen’t work. I made what you did.