PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

How to block while waiting for an event to fire

How to block while waiting for an event to fire

Jun 23 2018, 2:02 AM PST

Problem

You want to use some of the others members of events.

Solution

Use several of the other methods besides connect.

local hit = Workspace.Part.Touched:wait()
print(hit)

Discussion

There are quite a few unknown members of events. One of the most useful is the :wait method. This function will wait until the event occurs and then return the values usually supplied as arguments to a callback function. Therefore if you only want to connect an event once, you should use the wait function.

Tags:
  • events
  • touch
  • wait