changing script from key based function to GUI button for dice roll game

I am making a simple roll a dice game, for which i have taken help from tutorial regarding the scripts. According to the script basically dice rolling script, it first roll the dice at the start of game and one have to press the spacebar key to again roll the dice. But i want to use the button instead of key for rolling the dice. That means player will have to press the button in an order to roll a die. I have tried to change the script but was unable to get the result. Any suggestions are highly acceptable. :slight_smile:

  1. Add a UI button your scene/prefab.

  2. Create a new method eg “RollDIce”

  3. Transit the code you are having in your Update method on space bar key Input to this method.

  4. Remove the Update method

    class DiceScript:MonoBehaviour

     void RollDice()
        //the code of player pressing the Space bar from update 


5)Now, assign the button action this RollDIce method from the inspector.