Search Unity

My Javascript isn't working!

Discussion in 'Scripting' started by Richard1234, Feb 27, 2015.

  1. Richard1234

    Richard1234

    Joined:
    Feb 17, 2015
    Posts:
    8
    Hi everyone. I recently started programming on javascript,but after applying a simple script on an object,the engine can't start the game,and it's shown an alert message down in the screen,that I don't know what mean. I think it's something wrong on my script,but I don't know exatly what. Here's a photo of my script and a photo of the screen when I try to start the game.


    Thanks since now :)
     
  2. Deleted User

    Deleted User

    Guest

    What's wrong with taking a screenshot?

    transform is non-static so you need to type "transform".
     
    Richard1234 likes this.
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Code should be posted as code, not a screenshot, and definitely not as a camera shot. Ditto for error messages; just copy and paste them as text (and clearly point out the specific line they refer to). Please don't go out of your way to make it difficult for people to help you, thanks.

    --Eric
     
    Richard1234 and Deleted User like this.
  4. kdubnz

    kdubnz

    Joined:
    Apr 19, 2014
    Posts:
    177
    as @supremegrandruler posted, Transform.position should be transform.position ( read the documentation)

    If you look at the error message you'll see the line number and description of the error.

    also : It seems that you have changed the name of the between the piccy captures ...
    Your script is named NewBehaviourScript1.js in the first piccy
    and Blablablabal,js in the second.

    also, for next time :
    Regarding the error message
    Google An instance of type "UnityEngine.Transform" is required
    https://www.google.com.au/search?q=...rome..69i57&sourceid=chrome&es_sm=93&ie=UTF-8
     
    Last edited: Feb 28, 2015
    Richard1234 likes this.
  5. Richard1234

    Richard1234

    Joined:
    Feb 17, 2015
    Posts:
    8
    Thanks for everyone who aswered! I simply changed "Transform" to "transform" as supremegrandruler said and it worked! I'm sorry for posting a photo istead of a screen shot,this won't happen again,I swear(I forgot how to do it,but know I know :))