Please use code tags: Using code tags properly
You’re probably gonna have to liberally sprinkle some Debug.Log() statements into the code above to see how it is running in your exact setup.
Also, the above code uses the legacy GUI system, which has been out of favor for half a decade now, in favor of the new UnityEngine.UI system. If you’re in it for the long haul you might want to consider working on a newer tutorial that uses the current UI system, as the GUI system is deprecated already in this release cycle and will soon go away.