rotate model onkeydown?

i mave made a small astoroid type game i want script to rotate the model(player) by -5 and 5 degrees on the y axies then the left key or right key is down but dont know what to do my attempt was

		if (Input.GetKeyDown("right")
		    (transform.localRotation.y5f);

but didnt work any help

try:

		if (Input.GetKey("right")
		    (transform.localRotation.y=f);

But a better way would be this:

		var rotationSpeed=10.0;
		var rot=Input.GetAxis("Horizontal");
		transform.localEulerAngles.y+= rot * Time.deltaTime * rotationSpeed);

hmmmmm nope heres my code for movement

	void Update () 
	{
		float amtToMove = Input.GetAxisRaw ("Horizontal")* PlayerSpeed *Time.deltaTime; // a value that allows to move a distance over 1 sec
								//.GetAxis gives a smooth movement Raw gives a snapping feel like old arcade games
		transform.Translate(Vector3.right * amtToMove);
		
		//Wrapping player going off screen and comming back on
		
		if (transform.position.x<= -7.5f)
			transform.position = new Vector3 (7.4f, transform.position.y, transform.position.z); // if player goes of the left bounds apper on the right -7.5 is the bounds 
		
		else if (transform.position.x>= 7.5f)
			transform.position = new Vector3 (-7.4f, transform.position.y, transform.position.z);
	
	if (Input.GetKeyDown("space"))
		{
			//fire prejectile	
			Vector3 position = new Vector3 (transform.position.x, transform.position.y + (transform.localScale.y / 2));
			Instantiate(PrejectilePrefab, position, Quaternion.identity); //make a prejectile
	
		}
	}

iv taken out the rotate as it didnt work my way i dont know if i have to refrence the mesh? or is it enougth that the script is linnked to the mesh.

if the mesh is a child of the gameobject you move using this script, you need to apply the rotation only to the mesh. because if you apply rotation to the gameobject, you will rotate it’s axis. you can either use global coordinates to move the gameobject (world coords) and rotate it (thus rotating the mesh aswell), or you can just add a script on the mesh, which will rotate it when a button is pressed (if you want the rotation to be as the movement script you can use getaxisraw, but if you want it to slowly rotate while it moves you can use getaxis).

you can add this to the mesh:

transform.localRotation.eulerAngles = new Vector3(0, Input.GetAxisRaw("Horizontal") * 5, 0);

I hope i understood your question, and my explanation helps you.