Quantcast
Viewing all articles
Browse latest Browse all 2891

Cannot disable a script in multiple Gameobjects from another script?

I tried to disable a script that in put in multiple Gameobjets by doing an arrey but i keep getting errors and don't know what to do, i've been stuck on this for many hours and this is really annoying me Here's the erros: ![alt text][1] And here's the code: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class Dangerous : MonoBehaviour { public GameObject objtodestroy; //public EndOfTheGame gameover; public Moving[] moving; void OnCollisionEnter(Collision collision) { if (collision.gameObject.name == "Sphere") { Score.scoreValue = 0; Money.goldValue -= 20; //gameover.GameOver(); foreach (GameObject Element in moving) { Element.GetComponent().enable = false; } //SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 3); } else if (collision.gameObject.name == "GameMaster") { Destroy(objtodestroy); } } } [1]: https://cdn.discordapp.com/attachments/671133911102783544/814333232551297024/unknown.png

Viewing all articles
Browse latest Browse all 2891

Trending Articles