GUI script problem

whats wrong with my script …i want the enemy to take 100 damage then the GUI pops up then when you press the button the enemy gets destroyed left with a dead replacement…like a ragdoll

If this script is on the enemy, you are destroying the enemy before you are finishing your code. Once you destroy it, it can no longer execute the code. Also, you are calling function OnGUI, but OnGUI is always called anyway.

In the future, please try not to ask “whats wrong with my script” but instead, tell us what you intend to do(as you did) and tell is what it is actually doing.

Let me know if that worked for you.

sorry forgot to mention this is a math game so when the cube/enemy takes 100 damage a GUI pops up with a multiple choice math question…and if you answer right the enemy gets destroyed and replaced with a dead replacement like a ragdoll:) …and if you answer wrong nothing happens yet…everything works but i cant get the cube to show the question only when it takes 100 damadge:(