tw.ui
Side: Client
Native UI elements: weapon wheel rank bar and countdown timer.
Functions
tw.ui.updateRank(level, xp, xp_required)
Displays a rank/XP bar in the weapon wheel UI.
| Parameter | Type | Description |
|---|---|---|
level | integer | Current level |
xp | integer | Current XP |
xp_required | integer | XP needed for next level |
tw.ui.initTimer()
Initializes the countdown timer UI resources. Must be called before startTimer.
Returns: number or nil — Returns nil if initialization fails.
tw.ui.startTimer(duration, low_threshold?)
Starts a visible countdown timer on screen.
| Parameter | Type | Default | Description |
|---|---|---|---|
duration | integer | — | Countdown duration in seconds |
low_threshold | integer? | — | Seconds remaining at which the timer turns red/urgent |
tw.ui.stopTimer()
Stops the countdown timer before it reaches zero.
tw.ui.finishTimer()
Destroys the timer UI resources. Call this when you are completely done with the timer.
Examples
Rank bar in weapon wheel
lua
-- Show player is level 5, with 340/500 XP
tw.ui.updateRank(5, 340, 500)Countdown timer workflow
lua
-- Initialize timer resources
local ok = tw.ui.initTimer()
if not ok then return end
-- Start a 2-minute countdown, turn red at 30 seconds
tw.ui.startTimer(120, 30)
-- ... game logic ...
-- Option A: stop early if player completes the task
tw.ui.stopTimer()
-- Always clean up when done
tw.ui.finishTimer()Timer for a timed event
lua
tw.ui.initTimer()
tw.ui.startTimer(60, 10) -- 60 seconds, urgent at 10s remaining
Wait(60000)
tw.ui.finishTimer()Notes
- Always follow the workflow:
initTimer()thenstartTimer()thenfinishTimer(). stopTimer()is optional — use it to end the countdown early without destroying the UI.finishTimer()must always be called to release UI resources, even ifstopTimer()was called.updateRank()is independent from the timer functions and can be used on its own.

