Cannot Locate Boolean in different script

Alright here is the problem, I am trying to get the moved boolean in one script so I can use it in another script. I’ve declared it public var moved : boolean = false; and it even shows up with the little check box in the inspector. But then I try to access it from a script attached to a different game object, like this:

Physics.Raycast(transform.position, Vector3.right, hit, 3.0);
if(hit.collider.gameObject.tag.Contains("tile")){
var tile = GameObject.FindGameObjectWithTag(hit.collider.gameObject.tag);
Debug.Log(tile.moved);

I get “Assets/Script/Shuffle.js(29,48): BCE0019: ‘moved’ is not a member of ‘UnityEngine.GameObject’.”

and I’ve tried Debug.Log(tile.GetComponent("Slider").moved); Slider.js being the name of the first script.

So anyone know why it cant be found?

You are at the gameobject and you need to reference the script component that is on the game object. Here is the idea in C#.

//Get GameObject
GameObject newBall = (GameObject)Instantiate (Ball);
//Get ScriptObject from the GameObject
BallScript bs = (BallScript)newBall.GetComponent (typeof(BallScript));
//You can now access properties.
bs.BallSpeed = 10;

missing “” for error-"Assets/Script/Shuffle.js(29,48)…‘moved’ is not a member…
Debug.Log(“tile.moved”);

take a look at this to take a function in another script

it work, just have another problem about the animation

You need to use GetComponent with the GameObject that’s returned by FindGameObjectWithTag. The variable is part of the script component, not the GameObject.

Thank you everyone for you suggestions. Unfortunately, as it usually is, the problem was just a stupid mistake. I had tile.GetComponent("Slider").moved when the quotes were unnecessary its just tile.GetComponent(Slider).moved