- Home /
"Only assignment, call, increment, decrement and new object expressions can be used as statements"
I just want to use an "int" that's on another script. I searched and this is how to do it, but it gives me this error if put the ";" in the end, "Only assignment, call, increment, decrement and new object expressions can be used as statements". But when i don't put the ";" it says "; expected".
{
void Awake()
{
GameObject.Find("Projectiles").GetComponent<ProjectilesValues>().Lasers;
}
}
You aren't doing anything here. You're calling GetComponent, and accessing the Lasers property, but then just doing nothing with it. Either set it to something, or save it in a variable.
Answer by Yoshinator2 · Aug 03, 2017 at 04:46 AM
Simple mistake, you just need to assign that returned value to a variable:
{
intVariable = GameObject.Find("Projectiles").GetComponent<ProjectilesValues>().Lasers;
}
If this solved your problem, please accept my answer :)
Your answer
Follow this Question
Related Questions
[C#] Quaternion Rotations with Input.GetAxis problems. 1 Answer
I'm trying to allow my character to only jump when grounded 1 Answer
3rd Person Camera to Rotate With the Player 0 Answers
How to detect an object which be in FOV of certain camera ? 1 Answer
(C# and Java)Unable to give the Damage from enemy bullet script to Player Health. 3 Answers