Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to stop a function if an event is fired until a countdown finishes?

Okay, the title is sure very confusing.

The thing is, I have a function that is connected to the Event event of a BindableEvent, for instance.

The Event fires whenever the gui is interacted with.

The function hides the gui if it is not interacted with for a set amount of time.

Now, this function doesn't run if it is already running,

but I'd like to know how to do that, the script waits 3 seconds. If in those 3 seconds the gui is intercated with, the function stops running doing nothing. If in those 3 seconds the BindableEvent doesn't get fired, the gui will hide.

Now, how would I make this function stop running if It's in that 3 second loop whenever that Event Event is fired?

Help is appreciated! Thanks!

I am not requesting code, but seeking for help on how to achieve this.

6 comments

0

this is very vague, what kind of guiobject are we working with here?

0

I'm working with BindableEvents, not guiobjects. As I said, I've got a BindabelEvent tht fires when the gui is used.

0

no, i mean what kind of guiobject are you interacting with, (textbox, textbutton, textlabel, frame) ???

0

A frame, but that doesn't have much related to the question or how to solve it

0

debounce?

0

Not at all. Nothing related with debounce here.

1 answer

I think returnig 'end' will do:

if script.Parent.MouseButton1Click then return end

3 comments

0

Uhhh that's not even what I was asking for.

0

You can't return end by the way. An end is not returned. It determines where do things end.

0

what

This discussion is preserved as it was. New answers, comments, and votes are closed.