Sending var value to another script

I know this has been asked many times. I have spent 4 hours looking over threads and I still don’t understand how this works… And yes, I read this page Link So if anyone has the patience to explain it one more time I would appreciate it. :frowning:

Here is what I have:

Object “Mover” has script named “MoverControls”
with - var Speed:float=0;

Object “Player” has a script named “PlayerControl”
with - var charSpeed:float=0;

The Speed value is constantly updating and I want to get the Speed value from “MoverControls” into my “PlayerControl” script so that I can use its value in other spots.

I tried placing this in my “MoverControl” script:

private var playerControl:PlayerControl;

function Update(){
	playerControl=gameObject.Find("Player").GetComponent(PlayerControl);
	playerControl.charSpeed = Speed;
}

but I keep getting this message:
"The name ‘PlayerControl’ does not denote a valid type (‘not found’)

try this:

private var playerControl : Transform;

function Update(){
	playerControl = gameObject.Find("Player");
	playerControl.GetComponent(PlayerControl).charSpeed = Speed;
}

Thanks for the quick reply!
Now I am getting this error:
" Cannot convert ‘UnityEngine.GameObject’ to ‘UnityEngine.Transorm’ "

Just a minor type oversight; playerControl should be typed as a GameObject here.

private var playerControl : GameObject;

function Update(){
	playerControl = gameObject.Find("Player");
	playerControl.GetComponent(PlayerControl).charSpeed = Speed;
}

Thanks FizixMan, that got rid of the error, however, I have a new one… this is melting my brain.

On the line:
playerControl.GetComponent(PlayerControl).charSpeed = Speed;

I get this error:
Unknown identifier: PlayerControl

Is your MoverControl in a folder like Standard Assets or Plugins while your PlayerControl is outside of those folders?

Does the name of your PlayerControl.js script file have a space in it?

Both the MoverControls and PlayerControl are in the Resources/Scripts folder, which is in the top level of the game hierarchy. I tried moving them to different folders, however I got the same result.

None of my scripts have spaces in them, and they are both .js files.

Does my scene hierarchy matter? Here is what I have:

(parent) - Mover(null object): MoverControls.js
(child) - Player(null object): PlayerControl.js