How would i make an override button?

Okay so, how do i make a stop code button? Like when i press the button it stops the whole code??
Its pretty self explanatory, i have tried researching but found nothing… tried thinking about it but i just dont know how to stop a code…

Thanks!

1 Like

Could you elaborate, please? What do you mean by stop code?

1 Like

Like for ex; i have a function that is supposed to run but i press the button then the function wont run anymore.

Assuming this is a basic script and not a module script, you could just enable the disabled property. This will terminate the running function. So just make your button enable the disabled property of the script.

1 Like

Don’t call the function anymore when the button is pressed?

1 Like

you can use error() to stop a script

1 Like

I am pretty sure you might want to look into promises. I have never used them in my game before but I have heard they are useful for these types of things.

I found the post I was looking for; How do you stop a function early?

1 Like

I assume this function runs a while loop, if so you can set a variable to be either true / false. Have the while loop run while the variable is true (while true do), then have the button change the variable to false upon being clicked. That should stop the loop from running again.

1 Like