[Solved] Call Javascript function from a button click

Hi, I made a Javascript function called buttonPressed()

function buttonPressed(){

I was wondering how I can call this from clicking a button in the scene.

Thanks in advance for the replies.

Hi, you should only need to create condition to check if button is clicked (Mouse is released, Touch is released, etc), and then make a sub event of Javascript code (using Plus icon on top right), and paste the code inside.

Got it now. Thank you

Think to add “Trigger once” condition with cursor conditions, because all events in the eventsheet are call once per frame, so in your case if you don’t add once condition, you will trigger loooooooooooooot of time the JSevent.
It’s a bad pratice for optimisation to miss “Trigger once”.