Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

cant access scripts :(

Discussion in 'Getting Started' started by niconacho2020, Mar 28, 2024.

  1. niconacho2020

    niconacho2020

    Joined:
    Jan 3, 2024
    Posts:
    8
    so im trying to access a script from another script. and they are attached to the same gameobject

    Screenshot 2024-03-27 at 8.48.28 PM.png Screenshot 2024-03-27 at 8.49.00 PM.png

    let me know if you need more info.

    this is gonna be such an obvious answerlolololololoolllolololololololololololo
     
  2. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,936
    It can't find a class named "PlayerScript". Are you sure your player script isn't lowercase? (playerScript)
     
    Ryiah likes this.
  3. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,703
    If both scripts are on the same object then the GameObject.Find is pointless at best and could screw things up. Get rid of it.
     
    Ryiah likes this.
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,753
    You started the name of one of your classes with a lower case letter while at least two other classes start with an upper case letter. You need to choose one approach and stick with it or you're going to end up with a lot of little headaches trying to remember which one you used.
     
    ArachnidAnimal and Chubzdoomer like this.
  5. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,700
    Please use code-tags and not images to show code.

    Thanks.
     
    APSchmidt likes this.
  6. niconacho2020

    niconacho2020

    Joined:
    Jan 3, 2024
    Posts:
    8
    this is is to access another script. not the playerscript
     
  7. niconacho2020

    niconacho2020

    Joined:
    Jan 3, 2024
    Posts:
    8
    ive changed all the class things to lowercase. didnt fix anything
     
  8. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    2,212
    ok, so dont make more changes

    tell us the current errors
    Show us the files involved so if it says error on mything.cs, show that, if the error refers to another class, show that.. etc
     
  9. niconacho2020

    niconacho2020

    Joined:
    Jan 3, 2024
    Posts:
    8
    well i figured it out. or something like that. (i basically copyed the code and put it in a new script, made the appreopriate adjustments and it worked!