I was working on a script when I needed to make it delay until an object was touched. I saw this post, and I implemented this line of code
repeat task.wait() until Object.Touched
After several modifications, I couldn’t get it to work. My goal here is to make the entire script wait until this event from this part get fired and make the script proceed.
Events on objects are RBXScriptSignal. Instead of using :Connect() to bind a function to all future triggers of this event, you can use :Wait() to yield the current thread until only the next event.
Have the main script call a function in which the part is created and a listener to it being touched is added, then return something random like “done” and call that function getting its return value, that will cause the code to yield until a value is returned from the function and it will only return a value thus stopping the part when the part is touched