Converting Code C# to JS

First, sorry for my english.

Hi Guys, i’m starting now on Unity and Coding.

I will make a Scroll Background.
And i’m with this code in C#, but i like more to code in JS.

I had tried to convert, but don’t work…

What changes i’ve to make to this code work properly?

Thanks!

using UnityEngine;
using System.Collections;

public class moveOffset : MonoBehaviour {

	private Material currentMaterial;
	public float speed;
	private float offset;

	// Use this for initialization
	void Start () {

		currentMaterial = renderer.material;
	
	}
	
	// Update is called once per frame
	void Update () {
	
		offset += 0.001f;
		currentMaterial.SetTextureOffset ("_MainTex", new Vector2 (offset*speed,0));
	}
}

That’s one of the most simples scripts. It only contains a few line of code which are actually different. It’s mainly the variable declaration and the method declaration:

#pragma strict

var currentMaterial : Material;
var speed : float;
private var offset : float;

function Start ()
{
    currentMaterial = renderer.material;
}

function Update ()
{
    offset += 0.001f;
    currentMaterial.SetTextureOffset ("_MainTex", Vector2 (offset*speed,0));
}