# How to use task.wait properly

**URL:** <https://forum.luduvo.com/t/how-to-use-task-wait-properly/4509>\
**Category:** Engine API\
**Tags:** scripting\
**Created:** [October 2, 2026, 10:21pm UTC](https://forum.luduvo.com/t/how-to-use-task-wait-properly/4509 "2026-10-02T22:21:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wildpaintbrush](https://api.luduvo.com/users/by-username/Wildpaintbrush/avatar/headshot?size=32) [@Wildpaintbrush](https://forum.luduvo.com/u/Wildpaintbrush)\
**Post date:** [October 2, 2026, 10:21pm UTC](https://forum.luduvo.com/t/how-to-use-task-wait-properly/4509/1 "2026-10-02T22:21:39Z")

</div>

So, recently (update 45, I think), task.wait was added to the engine. Cool! The issue? Well… _ahem_

```markdown
scripts/Script.server.lua:1: task.wait yields only inside a task function or a coroutine

```

I don’t really know what a task function is, and since it also can run in a coroutine, why limit it there? Is it a bug? Something Intentional? I’m just a little confused, and would like a little more clarification if possible.

I think I’m most confused at the “task function” thing. Does that mean I could only do something like… say,

```auto
task.delay(1, function()
       task.wait(1)
       print("FAAA")
end)

```

Or am I completely misunderstanding how task.wait() works?

---

<div class="post-metadata">

**Author:** ![yeno](https://api.luduvo.com/users/by-username/yeno/avatar/headshot?size=32) [@yeno](https://forum.luduvo.com/u/yeno)\
**Post date:** [October 2, 2026, 11:35pm UTC](https://forum.luduvo.com/t/how-to-use-task-wait-properly/4509/2 "2026-10-02T23:35:08Z")

</div>

task.wait is jank uhh but yea it just cant run in script thread thats ab it

its only like this bc igor uses lua\_pcall to init the thread (i added wait b4 wait and it was 90% broken bc of that)

---

<div class="post-metadata">

**Author:** ![Wildpaintbrush](https://api.luduvo.com/users/by-username/Wildpaintbrush/avatar/headshot?size=32) [@Wildpaintbrush](https://forum.luduvo.com/u/Wildpaintbrush)\
**Post date:** [October 3, 2026, 12:02am UTC](https://forum.luduvo.com/t/how-to-use-task-wait-properly/4509/3 "2026-10-03T00:02:53Z")

</div>

Ough… I hope that changes soon :(

---

<div class="post-metadata">

**Author:** ![primiti\_ve](https://api.luduvo.com/users/by-username/primiti_ve/avatar/headshot?size=32) [@primiti\_ve](https://forum.luduvo.com/u/primiti_ve)\
**Post date:** [October 3, 2026, 11:31am UTC](https://forum.luduvo.com/t/how-to-use-task-wait-properly/4509/4 "2026-10-03T11:31:04Z")

</div>

```lua
task.defer(function()
       task.wait(1)

       print("FAAA")
end)

```

---

<div class="post-metadata">

**Author:** ![Wildpaintbrush](https://api.luduvo.com/users/by-username/Wildpaintbrush/avatar/headshot?size=32) [@Wildpaintbrush](https://forum.luduvo.com/u/Wildpaintbrush)\
**Post date:** [October 3, 2026, 5:03pm UTC](https://forum.luduvo.com/t/how-to-use-task-wait-properly/4509/5 "2026-10-03T17:03:27Z")

</div>

Ah, I see!

So task.defer sort of marks the function as “waitable”. Gotchya.

Thanks!

---

<div class="post-metadata">

**Author:** ![primiti\_ve](https://api.luduvo.com/users/by-username/primiti_ve/avatar/headshot?size=32) [@primiti\_ve](https://forum.luduvo.com/u/primiti_ve)\
**Post date:** [October 3, 2026, 9:52pm UTC](https://forum.luduvo.com/t/how-to-use-task-wait-properly/4509/6 "2026-10-03T21:52:32Z")

</div>

iirc, `task.defer` waits until the next frame/tick to run the contents of the script

but yes, `task.defer` and `task.delay` are the only ways you can run functions in which you can use `task.wait` inside. i don’t think this is expected behaviour, although it wouldn’t surprise me at this point

---

<div class="post-metadata">

**Author:** ![Wildpaintbrush](https://api.luduvo.com/users/by-username/Wildpaintbrush/avatar/headshot?size=32) [@Wildpaintbrush](https://forum.luduvo.com/u/Wildpaintbrush)\
**Post date:** [October 3, 2026, 10:58pm UTC](https://forum.luduvo.com/t/how-to-use-task-wait-properly/4509/7 "2026-10-03T22:58:57Z")

</div>

Honestly, `task.wait()` is incredibly useful, and while I understand that they’ve designed the API in this way since most generally you shouldn’t be de-syncing scripts (which apparently `wait()`/`task.wait()` does), I mean… It’s been fine on Roblox, P\*lytoria, and Vortex, so I really don’t think that it could be that bad.

But eh, I’m no professional, either. I’m very much still finding my footing as a programmer, and I couldn’t really tell you the difference between an array and a dictionary. In any case, at least we have _some_ built-in form of `wait()`ing.

(Dunno if we can say 'Toria in full, so I’m censoring to save face. I still think it’s sorta ridiculous and childish that we can’t say it because “Luduvo” is a banned term on the 'Toria, but whatever.)

---

<div class="post-metadata">

**Author:** ![yeno](https://api.luduvo.com/users/by-username/yeno/avatar/headshot?size=32) [@yeno](https://forum.luduvo.com/u/yeno)\
**Post date:** [October 4, 2026, 12:54am UTC](https://forum.luduvo.com/t/how-to-use-task-wait-properly/4509/8 "2026-10-04T00:54:52Z")

</div>

or coroutine as it makes a new thread
