{ // Run every frame void Update() { // Check for F10 key if (Input.GetKeyDown(KeyCode.F10)) { // Loop through all staff AI scripts that were found foreach (StaffAINew SAI in FindObjectsOfType<StaffAINew>()) { // Get the staffHP component and damage it with -1000HP SAI.GetComponent<staffHP>().Damage(1000); } } } }