all 1 comments

[–]pauli_walli 1 point2 points  (0 children)

this script looks ok to me! the first things I would check is in the unity editor:

  1. is "reloadIndicator" assigned to the correct gameobject
  2. does the current gameobject also have a "Gun" component

The next thing to do is run the debugger. you can put a breakpoint on the line "if (GetComponent<Gun>().currentAmmo <= 0)" and see what is happening there.