Your code hides the cursor. Nothing more nothing less. It just contains quite a lot of unnecessary "decoration".
This is the core of the code:
As it says it hides the cursor.
It does not make your game ignore the mouse input. You didn't mentioned how your game deals with mouse input. Therefore you get a very generic answer:
- let your logic ignore the mouse input
When you provide more details you might get a more specific answer that fits your current situation.
... the cursor to be disabled to prevent the game from clicking other menu buttons ...
I suggest you disable "clicking". There are many options to do so:
remove the clickable object (when you need clicking again - add another clickable object)
add a sensor that indicate if clicking is active or not e.g. via property
switch states to enable/disable clicking