Error using return Mathf.Clamp

I’m still somewhat new to coding with C#, so I am unsure if there’s a different way of doing this. I’m getting two errors with return Mathf.Clamp (angle, min, max);

Assets/NewScripts/UserCamera.cs(158,17): error CS0127: `UserCamera.ClampAngle(float, float, float)': A return keyword must not be followed by any expression when method returns void

Assets/NewScripts/UserCamera.cs(158,17): error CS0029: Cannot implicitly convert type float' to void’

	void ClampAngle (float angle, float min, float max)
	{
		if (angle < -360)
			angle += 360;
		if (angle > 360)
			angle -= 360;
return Mathf.Clamp (angle, min, max);

}

Your function is a “void” type, which means it has no return type.

That said, you don’t appear to be changing any variables in the script through this function, so I would recommend using:

float ClampAngle (float angle, float min, float max)

This would support your return call, which presently returns a “float” value.

Then, to utilize this function, you would use something like

myAngle = ClampAngle(myAngle, minAngle, maxAngle);

in your script.