> For the complete documentation index, see [llms.txt](https://docs.streamavatars.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.streamavatars.com/lua-scripting-api/api-reference-and-tips/global-functions/yield.md).

# yield

```lua
return function
    local timeCounter = 0;
    local x = 0;
    local speed = 5;
    
    wait(3.5); --pauses script 3.5 seconds before continuing...
    
    while timeCounter < 5 do --after 5 seconds this while loop will end
    
        local delta = yield();  --useful for doing work over a period of time
        
        --yield returns the time it took from last frame to this frame in seconds.
        --yield also pauses the script each frame so the while loop doesn't lock the application up
        --while doing work.
        
        timeCounter = timeCounter + delta;
        
        --you can also use the deltaTime to advance the position of something
        x = x + speed * delta; --at a rate of 5units per second, x moves right.
    end
end
```

{% hint style="success" %}
Find details on deltaTime at this link:\
[API Reference & Tips](/lua-scripting-api/api-reference-and-tips.md#pre-data)&#x20;
{% endhint %}
