Raycast problems!

im making a simple skateboard game with the design3 tutorial. the raycast code i have copied does not seem to work. i want it to tilt the skater as he goes up a vertical ramp to make it look realistic. i am a beginner in coding and even more of a beginner on raycasts. i dont know if my code is wrong or there is just something wrong with my model i am using. when ever i go up a ramp it doesnt turn then when i go back down the ramp it wont let me rotate the character left or right untill im on another ramp then i can turn the character but not on the flat plane for some reason. hope this all makes sense.

My code.

var rotateSpeed = 90;
var pushImpulse = 3.5;
var maxSpeed = 12;
var decayRate = 0.1; 

private var character : CharacterController;
private var trans : Transform;
private var speed = 0.0; 
private var targetRot : Quaternion;

function Start ()
	character = GetComponent(CharacterController);
	trans = transform;

function Pushing()
	speed += pushImpulse;
	speed = Mathf.Min(speed, maxSpeed);

function Update ()
	var horizontal = Input.GetAxis("Horizontal");
	trans.Rotate(0,rotateSpeed * horizontal * Time.deltaTime,0);
	if (character.isGrounded && Input.GetKey(KeyCode.UpArrow))
	var moveDirection = trans.forward * speed; 
	moveDirection += Physics.gravity;
	character.Move(moveDirection * Time.deltaTime); 
	var ray = new Ray(trans.position + Vector3.up, -Vector3.up);
	var hit : RaycastHit;
	if (Physics.Raycast(ray, hit, 100))
		 targetRight = Vector3.Cross(hit.normal, trans.forward);
		 targetForward = Vector3.Cross(targetRight, hit.normal);
		 if ( character.isGrounded )
		 		targetRot = Quaternion.LookRotation(targetForward, hit.normal);

	trans.rotation = Quaternion.Slerp(trans.rotation, targetRot, 5 * Time.deltaTime);
	if (character.isGrounded) 
	//Stops character when slowed down enough
		if (speed < 0.3)
			speed = 0;

	//simple code to add friction to character
		speed -= decayRate * Time.deltaTime * speed;


OK, so reading you code, I realise the answer:

They are doing Quaternion Interpolation, using Lerp and I guess they are calculating it wrong.
Instead the code they use, try this:

//At the start of your script
//Just defining the variables here, for both typecasting and optimisations
var targetDir:Vector3;
var ray:Ray;
var hit:RaycastHit;

//Inside the Update function
//Cast the ray relative to player
ray = Ray(trans.position + trans..up, trans.down);

//If we are on the ground and we get a raycasthit
if (Physics.Raycast(ray, hit, 100)) {
    if (character.isGrounded) {
        targetDir = hit.normal;

//Smoothly move towards the new direction
transform.up = Vector3.Slerp(transform.up, targetDir, 5 * Time.deltaTime);

Hope this helps,