Mouse Click On UI function

How do I make a function for when mouse clicks on UI

Use either a Button component for whichever piece of UI you want to click on, or add an EventTrigger component to it and add an “OnPointerClick” event to it either from the inspector or in code.