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

Is there any way to ask the script to wait and only proceed if an event(for example:)?

is there any way to ask the script to wait and only proceed if an event? (for example: "MouseButton1Click" event)

tried to use: Wait (Button.MouseButton1Click) but it did not work

1 comment

1

Button.MouseButton1Down:Wait()

1 answer

✓ Accepted answer

I made a quick textbutton script: https://imgur.com/a/q4c3yNq and tested some ways to yield a current thread until the event has been called (idk the right vocab).

:Wait() works.

script.Parent.TextButton.MouseButton1Down:Wait();

print('woo hoo')

Another way is to place a loop which yields the current thread and breaks when a condition is met, (for mine I used a boolean.)

local Bool_1 = true;
script.Parent.TextButton.MouseButton1Down:Connect(function()
	Bool_1 = false;
end);

repeat 
	wait();
until not Bool_1;

print('woo hoo')

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