Why i cant make reference to another script

why i cant make reference to the another script,
using UnityEngine;

public class monsterdamage : MonoBehaviour
{
public int damage;
public Playerhealth playerhealth;

// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
    
}

// Update is called once per frame
void Update()
{
    
}

}

1 Like

Well, you replied that I was right to my post here, about an hour ago: https://discussions.unity.com/t/whats-wrong-in-this-code-its-done-thanks/1559108/4, when I said: “When asking a question, you should always provide as much information as possible, such as what you’re trying to achieve, what you’ve attempted so far, what’s happening, what you expected to happen.”

Why don’t you start trying that now? Like, what is the script you want to have a reference to? What ways have you tried to make a reference to it, what has happened with the things you tried and couldn’t make a reference to it, and what you expected to happen?

ok i was try reference to player health script from tutorial named just add enemies episode 1 minute 5:5 and i followed all what he did u can know from there what i did and thanks for help

sorry thats my first time here

Is this the tutorial? https://www.youtube.com/watch?v=KF3EVjOhN4c

Is the PlayerHealth the script you can’t have a reference to?

From what I can see, if PlayerHealth is the script you want to reference, then at 6:30 in the tutorial, he drags and drops the Wizard Boy GameObject into the editor. However, your script has a field named Playerhealth with a lowercase “h” while the tutorial’s script is called PlayerHealth with a capital “H” Because capitalization matters, the editor treats these as different scripts, so you wouldn’t be able to drag and drop it as shown if you have named your script with a capital “H”.

Make sure to follow the tutorial exactly, step by step, and pay close attention to every detail, no matter how small it may seem. If something doesn’t work, go back to the tutorial and double-check that you’ve followed every step exactly as shown.

when i start write public pla… there are no auto compelete , i copied the script name and nothing are going ok

i searched on youtube how to make a reference to a script and i cant find anything

the different is he put the script in empty object i didnt i put it in sqaure object , that can do anything?

can that be a bug?

i changed to that ,
public class playerhealth

now no errors but i cant see player health in the place i will drag the script to

I can’t watch the whole tutorial and I can’t know everything you have done, in any case it most certainly is not a bug.

I will repeat it again because it is very important: make sure to follow the tutorial exactly, step by step, and pay close attention to every detail, no matter how small it may seem. If something doesn’t work, go back to the tutorial and double-check that you’ve followed every step exactly as shown. Also, don’t just blindly do everything in the tutorial, at each step, try to understand why it is happening.

1 Like

ok i will try again tomorrow , thanks