Using a Gui slider to rotate the character

I’m trying to figure out how to have a slider (GUI) manipulate the rotation of my character and the fpscamera. I only want it to go 180 degrees (left - right) because I don’t want the player to look backwards. How would I go about this?

(I’m writing in JS)

This script attached to an object will display a horizontal slider and allow you to rotate that object -90 to 90 degrees. My guess is there is more to your problem which you have not detailed in your question.

#pragma strict

var hSliderValue : float = 0.0;

function Update() {
	transform.eulerAngles = Vector3(0.0, hSliderValue, 0.0);
}
	
function OnGUI () {
	hSliderValue = GUI.HorizontalSlider (Rect (25, 25, 200, 30), hSliderValue, -90, 90.0);
}