GUI.Button click trigger game object

How can I prevent a GUI.Button click go through the Game area, currently when I was clicking on the GUI.button which cover a game object it will also trigger my game object action too.

pull the raycast code you are doing out of the update loop you are using for it. Instead, in your gui code when you check for button presses, assign a mouse action that the gui code won’t use as your raycast method. If your gui code doesn’t use a mouse down event, for example, then you can add your raycasting there.