How to make the camera rotation stop at an exact angle?

Hey, im working on a character movement script. I’ve got a problem with limiting my camera rotation. The script actually limites the rotation of the camera, but not exactly at the point i’d like to. Instead of stopping the camera at 0.3 (or -0.3), it does stop it at 0.3x (or -0.3x) which completly blocks the camera rotation. Any tips?

using UnityEngine;
using System.Collections;

public class Movements : MonoBehaviour 
{
    public float speed = 10.0F;
	public float RotSpeed = 150.0F;
	void Update() 
	{
		// Getting axises
        float forwardBackward = Input.GetAxis("Vertical") * speed * Time.deltaTime; 
		float leftRight = Input.GetAxis("Horizontal") * speed * Time.deltaTime;
		float RotLeftRight = Input.GetAxis("Mouse X") * RotSpeed * Time.deltaTime;
		float RotUpDown = Input.GetAxis("Mouse Y") * RotSpeed * Time.deltaTime;
		
		// Doing movements
        transform.Translate(0, 0, forwardBackward);
		transform.Translate(leftRight, 0, 0);
		transform.Rotate (0, RotLeftRight, 0);
		
		if(transform.rotation.x > -0.3 && transform.rotation.x < 0.3)
			transform.Rotate(RotUpDown, 0, 0);
		
    }
}

Try using local euler angles instead of transform rotation. I noticed the camera look on the mouse Y axis was getting stuck. Try this.

using UnityEngine;
using System.Collections;

public class Movements : MonoBehaviour 
{
	public float speed = 10.0F;
	public float RotSpeed = 150.0F;
	public float minY = -30.0f;
	public float maxY = 30.0f;
	float forwardBackward;
	float leftRight;
	float RotLeftRight;
	float RotUpDown;
	Vector3 euler;

	void Start()
	{
	
	}
	
	
	void Update() 
	{
		transform.localEulerAngles = euler;
		// Getting axes
		forwardBackward = Input.GetAxis("Vertical") * speed * Time.deltaTime; 
		leftRight = Input.GetAxis("Horizontal") * speed * Time.deltaTime;
		RotLeftRight = Input.GetAxis("Mouse X") * RotSpeed * Time.deltaTime;
		RotUpDown = Input.GetAxis("Mouse Y") * RotSpeed * Time.deltaTime;
		
		// Doing movements
		transform.Translate(0, 0, forwardBackward);
		transform.Translate(leftRight, 0, 0);
		euler.y+= RotLeftRight;
		
		euler.x+= RotUpDown;
		
		if(euler.x >= maxY)
			euler.x = maxY;
		if(euler.x <= minY)
			euler.x = minY;
	}
}