I solved this
Changing Variable Outside of the Script
I have been working out this problem for a while now to no avail. Although I've attempted to read many forums and answer pages on this topic I still seem to struggle when it comes to my case.
I am trying to access a variable inside my script called ballScript (JS) from my multiplayer script RandomMatchmaking (C#). These lines of code keep getting an error of the name myBallScript not existing in the current context.
myBallScript = GameObject.Find ("Ball").GetComponent("ballScript");
if(myBallScript.respawn = true)
{
GameObject player = PhotonNetwork.Instantiate("playerprefab", orangeSpawnPoint, Quaternion.identity, 0);
}
My ending goal is to access the ballScript script that is attached to Ball and then be able to monitor the respawn boolean to check if it is true or not. If it is true, I want to instantiate a prefab. It would also be useful to be able to change the respawn boolean from true to false if needed.
Thank you and I would love a timely response due to deadlines.
Follow this Question
Related Questions
How can I access an int variable from another script? 1 Answer
Need a variable to exist in the current context - not sure where to start 0 Answers
How can you add a function to a variable. Such as string.ToUpper() ? 1 Answer
Unity 5 Accessing other scripts problem 2 Answers
Accessing a non-static string variable in another script C# 1 Answer