Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How to use wait() in a ModuleScript without causing delays?

Asked by 5 years ago

I have a ModuleScript that takes a sound, plays it, then waits for it to end, then deletes it. But when I actually use it, the modulescript causes pausing all over the script that's calling it. How do you avoid this? I want to have the script run all the way through without a pause in the middle of it from the ModuleScript but I don't know how

0
Use the event "Ended" instead of your own wait function and it won't be an issue http://wiki.roblox.com/index.php?title=API:Class/Sound/Ended Vulkarin 581 — 5y
0
That does not answer his question at all. User#21908 42 — 5y
0
Why not? He said himself that his module script is just waiting for the sound to end. Why use a coroutine or spawn when a built in roblox event will do it for you? Vulkarin 581 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

You can use coroutines. Spawn is the one I generally use. If anyone has a better answer please comment to me down below because I would love to know it. Hope this helps and have a great day scripting!

Ad

Answer this question