Self moving paddle

I am creating a 3d platform game and need to write a script so that the paddle moves to the left and right blocking the players path. So far i have this written:

var fwdPaddleTimer: float = 3.0;

var revPaddleTimer: float = 3.0;

function Update () {

//Deal with the paddle moving forward

 //Count down 
 fwdPaddleTimer -= 0.1;
 //If the fwdPaddleTimer goes below 0 set it to 0
 if(fwdPaddleTimer < 0)
 {
 	fwdPaddleTimer = 0;
 }
 //If the fwdPaddletimer is less than 3 but above 0 move to the left
 if(fwdPaddleTimer < 3 && fwdPaddleTimer > 0)
 {
 	transform.Translate(Vector3.left * Time.deltaTime);
 }

//deal with the paddle moving backwards

//If the fwdPaddleTimer is equal to 0 count down the revPaddleTimer
if(fwdPaddleTimer == 0)
{
	revPaddleTimer -= 0.1;
}
//If the revPaddleTimer is less than 0 reset it to 0
if(revPaddleTimer < 0)
 {
 	revPaddleTimer = 0;
 }
 //If the revPaddleTimer is less than 3 and greater than 0 move to the right
 if(revPaddleTimer < 3 && revPaddleTimer > 0)
 {
 	transform.Translate(Vector3.right * Time.deltaTime);
 }

}

This moves the paddle to the left until the timer runs out then moves the paddle right until the other timer runs out.

I am stuck on how to code it so that this process is repetitive.

Any help is appreciated, thanksssss =)

You approach is not good. Why don’t you try ITween for Unity.

You can get it here

Thanks for the help. iTween is brilliant!

NC90