ProgressBar
The progress bar system provides visual feedback for long-running operations with smooth animations. Progress bars automatically animate from 0% to 100% over the specified duration.


progress
Display a progress bar with automatic animation and professional styling.
Parameters:
playerId(number, server-side only): Player server ID to send the progress bar tooptions(table): Progress bar configuration optionsduration(number): Duration in milliseconds for the progress to completelabel(string, optional): Text label to display (default: 'Loading...')type(string, optional): Progress type - 'circular' or 'linear' (default: 'circular')position(string, optional): Position on screen (default: from config)showPercentage(boolean, optional): Whether to show percentage text (default: from config)color(string, optional): Progress bar color - hex color or theme color (default: from config)canCancel(boolean, optional): Whether the progress can be cancelled (default: false)cancelKey(string, optional): Key to cancel progress (default: 'X')id(string, optional): Custom progress bar ID (default: auto-generated)size(string, optional): Progress bar size - 'small', 'medium', 'large' (default: 'medium')thickness(number, optional): Progress bar thickness for circular type (default: 8)backgroundColor(string, optional): Background color overridetextColor(string, optional): Text color overridegradient(boolean, optional): Enable gradient effect (default: true)animation(string, optional): Animation style - 'smooth', 'pulse', 'glow' (default: 'smooth')
Returns: number|boolean - Progress bar ID on success, false on failure
Example:
hideProgress
Hide the currently active progress bar immediately.
Returns: boolean - Success status
Example:
getProgressState
Get the current state of active progress bars.
Returns: table - Progress state information
active(boolean): Whether a progress bar is currently activeid(string): Current progress bar IDprogress(number): Current progress percentage (0-100)duration(number): Total duration in millisecondselapsed(number): Elapsed time in millisecondscanCancel(boolean): Whether current progress can be cancelledlabel(string): Current progress label
Example:
progressAll (Server-side only)
Send a progress bar to all online players simultaneously.
Parameters:
options(table): Progress bar configuration options (same as progress function)
Returns: boolean - Success status
Example:
hideProgressPlayer (Server-side only)
Hide progress bar for a specific player from server-side.
Parameters:
playerId(number): Player server ID
Returns: boolean - Success status
Example:
Progress Types
Circular Progress
Ideal for indeterminate operations and loading states.
Linear Progress
Perfect for file operations and step-by-step processes.
Positioning System
Progress bars support a comprehensive 9-position grid system:
Recommended Positions:
'center'- Screen center (default for circular)'top-center'- Top center'bottom-center'- Bottom center (default for linear)
Corner Positions:
'top-left'- Upper left corner'top-right'- Upper right corner'bottom-left'- Lower left corner'bottom-right'- Lower right corner
Side Positions:
'center-left'- Left side center'center-right'- Right side center
Size and Styling Options
Size Variants
Color Customization
Animation Styles
Smooth Animation (Default)
Pulse Animation
Glow Animation
Cancellation Handling
Basic Cancellation
Advanced Cancellation with Callback
Server-Side Usage
Progress for Specific Player
Progress for All Players
Sequential Server Operations
Conditional Progress Operations
Configuration
Configure progress bar defaults in config.lua:
Advanced Examples
Multi-Step Progress with Updates
Progress with Real-time Updates
Progress with State Persistence
Server-Side Batch Operations
Events
The progress system triggers the following events:
Client-Side Events
b2lib:progress:started- Triggered when a progress bar startsb2lib:progress:updated- Triggered during progress updatesb2lib:progress:completed- Triggered when progress completesb2lib:progress:cancelled- Triggered when progress is cancelled
Server-Side Events
b2lib:server:progress- Internal event for server-to-client progressb2lib:server:progressAll- Internal event for broadcasting progress
Best Practices
Choose Appropriate Types - Use circular for indeterminate operations, linear for measurable progress
Provide Clear Labels - Use descriptive labels that inform users what's happening
Consider Duration - Match progress duration to actual operation time when possible
Use Cancellation Wisely - Allow cancellation for long operations that users might want to abort
Position Strategically - Place progress bars where they won't obstruct important UI elements
Customize for Context - Use appropriate colors and sizes for different operation types
Handle Edge Cases - Always validate parameters and handle failures gracefully
Test Performance - Ensure progress animations don't impact game performance
Provide Feedback - Show completion notifications after progress finishes
Use Server-Side for Critical Operations - Important progress should be managed server-side
Troubleshooting
Progress Not Showing
Check Duration Parameter: Ensure duration is provided and is a positive number
Verify B2Lib Initialization: Confirm B2Lib is properly initialized
Validate Position: Ensure position value is valid
Check Console Errors: Look for error messages in the console
Test with Simple Example: Try a basic progress bar without optional parameters
Progress Animation Issues
Check Update Interval: Verify updateInterval in config is appropriate (16ms for 60fps)
Monitor Performance: Ensure other scripts aren't causing frame drops
Test Different Types: Try both circular and linear types
Disable Effects: Temporarily disable gradient and animation effects
Cancellation Not Working
Verify canCancel Setting: Ensure canCancel is set to true
Check Cancel Key: Verify the cancel key is properly configured
Test Key Binding: Ensure the cancel key isn't bound to other functions
Monitor State: Use getProgressState() to check cancellation status
Server-Side Issues
Check Player Validity: Ensure player ID is valid before sending progress
Handle Disconnections: Account for players disconnecting during progress
Validate Permissions: Check player permissions before showing progress
Test Event Triggering: Verify server events are properly registered
Performance Issues
Limit Concurrent Progress: Avoid multiple progress bars simultaneously
Optimize Update Frequency: Adjust update interval based on needs
Use Appropriate Sizes: Smaller progress bars have better performance
Monitor Memory Usage: Check for memory leaks with long-running progress
Last updated