Changing Walkspeed for Run Button - Help!

Hi Im new to Unity3D and recently came from Game Maker to Unity3D for more game making options.

I am stuck on making a Run Button for my 2D platformer, I am using Javascript. I have some idea on how it all works, But I am still new to Unity so I need to get a custom to all its functions it has to offer. I have a run button to increase the walkspeed to a higher value by pressing a button say like left shift or something while moving left or right, although I am using my Xbox controller for this so it would be the whole "Input.GetButton("Fire1) and “Input.GetAxis(“Horizontal”)”

Although I am confused. Because I have rewritten this script out many times in many different spots and searching around I have been told to use it under the Function Update(). But it still does not work. I have tried making it its own function to no avail. Nor will it work under the normal movement (Even though the speed defiantly increased just it did it by default so it bought me to square one).

And I am absolutely stumped at this and would require some assistance as I have looked around all over the internet or to my knowledge I have and have found no solutions.

This is my code:

if (movement.enabled && Input.GetButton("Fire1")&& Input.GetAxis("Horizontal")) 
movement.runSpeed = 10 * movement.walkSpeed;  // < ---- RUNNING 

I am however using this script with Javascript, I am using a character controller AND it is under the “function Update()” section. And Im sorry if I make some of you slap your heads in disbelief if this is simple or if the code isn’t great. I just would like some guidance or at least a step in the right direction. Again, I am new.

Thank you for reading this and hope you help me out as soon as possible.

in function update, the computer is constantly scrolling and reading through your code.
outside function update, the computer only reads it once and never again. outside function update is a good place to declair varables or whatever calculations / lookups that need to happen only once for use in update.

well im not familier with your controller setup. you can figure out the buttons yourself. but ill write a super basic code to surely make your object move at two speeds. this is a working code to get you thinking in the right direction.

    var speed:float;
    function Update(){
    if (Input.GetKey ("space")){speed=.05;}
    if (Input.GetKey ("up")){transform.position.x=transform.position.x+speed;}

attach this to the object and your guy moves if you push the up arrow on the keyboard. push space and he moves at a different speed. you can change the buttons to whatever ya want and add the other directions. i just thought you seeing something work might help.

all my coding expirence is for unity. i am only familiar with javascript
i am looking at your code wondering what the dots are for after your variables.
all the references dont follow your format you are using.
the simplest way to use varables is to declair them at the top of your script before function update. this way they show in the editor under your object so you can see whats happening.

for example your movement seems to be a true/false variable you want.
to get you going put all your variables at the top like this.

var movement=false;
var speed:float;
var spot:Vector3;

function Update(){

if(movement==true){dosomething here;}
if(speed==10)     {dosomething else;}

putting the dots is only for specifying funtions not variables in if statements. usually you only use = or == or < in if statements for variables for javascript in unity. of course good old && and || work too!