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

How to add a Delay to a script?

Hey guys, I'm trying to delay something happening but it's not working very well ... can you help me?

5 answers

Try adding "wait()" inside of the script.
-- Place a number within the parenthesis. That number will represent seconds.

Be sure to place it where you want to "Delay" in order to make it work correctly.

2 comments

0

You should also note that the delay is in seconds.

0

Ahh, yes. Edit Incoming.

You need to be more specific. Do you mean wait()?

1 comment

0

He's referring to the wait function, yes.

Delay() can also be used if you wish to use a function after a delay with two arguments (elapsed time, place time). wait() is generally a better way, though, with an argument in seconds for amour of time to wait. wait() can also be used similar to a connection line.

pathway = --put the pathway of whatever item you want to wait for here. Don't include the actual event.
pathway.event:wait()

Be aware that I am not a professional scripter.

It's simple. Here, you can use the wait() function. The number of seconds needed to wait will be put in the parentheses. For example, 0.1 will wait for 100 milliseconds(0.1 seconds).

while true do
	wait(1) --waits for 1 second.
	print("waited 1 second!") --prints into the output.
end

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