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

how to abort the wait() whan something is done ?

example my code is

print("PressButton")
wait(10)
print("TEXT")

when I'm Still not pressing the button , it will wait 10 seconds until print("TEXT") gets executed but when i pressed the button , even it its in the procedure of waiting , it will print the TEXT , you know what i'm sayin' ? it's like it willskip the wait(10)progress and continue to the print("TEXT")

1 answer

✓ Accepted answer

I'm pretty sure this should work.

Basically all you needed was a function to run on the event of clicking the button, not once you start the game in Roblox Studio.

local button = workspace.Button -- or whatever you have the button named in the workspace
local click = button.ClickDetector -- you would need to put a click detector inside the button

click.MouseClick:Connect(function()
	print("pressButton")
	wait(10)
	print("TEXT")
end)

Another thing you could have done if you wanted the wait to stop right when the player pressed the button you could do

local button = workspace.Button
local click = button.ClickDetector

print("pressButton")
click.MouseClick:Connect(function()
	print("Text") 

To sum it up, the first one will wait 10 seconds when the player pressed the button while the second one will print Text once the player clicks the button

If I helped remember to mark my answer as "answered the question" it'll help both of us

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