Text UI
The Text UI system provides contextual text displays with optional keybind hints and icons. Perfect for showing interaction prompts, status information, and helpful hints that appear at specific screen positions.

textUI
Display a contextual text UI element with customizable styling and positioning.
Parameters:
playerId(number, server-side only): Player server ID to show text UI tooptions(table|string): Text UI configuration object or simple text stringtext(string, required): Text content to displaykeybind(string, optional): Keybind to display (e.g., 'E', 'F', 'ENTER', 'SPACE', 'TAB')key(string, optional): Alternative parameter name for keybind (same as keybind)icon(string, optional): Lucide icon name to display alongside textposition(string, optional): Display position on screen (default: from config)showBackground(boolean, optional): Show background panel (default: from config)fadeTime(number, optional): Fade animation duration in milliseconds (default: from config)backgroundColor(string, optional): Custom background color override (CSS color)textColor(string, optional): Custom text color override (CSS color)borderColor(string, optional): Custom border color override (CSS color)id(string, optional): Custom text UI identifier for tracking and management
Returns: boolean - Success status
Example:
hideTextUI
Hide the currently active text UI element with fade animation.
Parameters:
playerId(number, server-side only): Player server ID to hide text UI for
Returns: boolean - Success status
Example:
isTextUIVisible
Check if text UI is currently visible and get active text UI information.
Returns: boolean|table - False if no text UI is active, or table with active text UI data
text(string): Current text contentkeybind(string): Current keybindicon(string): Current iconposition(string): Current positionid(string): Text UI identifier
Example:
Position Options
Text UI supports 9 different screen positions for optimal placement:
'top-left'- Top left corner of screen'top-center'- Top center of screen'top-right'- Top right corner of screen'center-left'- Middle left of screen'center'- Center of screen'center-right'- Middle right of screen'bottom-left'- Bottom left corner of screen'bottom-center'- Bottom center of screen (default)'bottom-right'- Bottom right corner of screen
Example:
Server-Side Usage
The Text UI module provides comprehensive server-side functionality for managing player-specific text displays:
Configuration
Complete Text UI configuration options in config.lua:
Advanced Examples
Interactive Object System
Vehicle Interaction System
Dynamic Status Display System
Mission Objective System
Dynamic Help System
Events
The Text UI module provides comprehensive event handling for monitoring and responding to text UI interactions:
Client Events
Server Events
Event Usage Examples
Best Practices
Use Strategic Positioning - Choose positions that complement gameplay flow and don't obstruct critical UI elements like minimap, health bars, or chat
Keep Text Concise and Clear - Use short, actionable messages that players can quickly understand at a glance
Implement Meaningful Keybinds - Display the actual keys players need to press, using consistent keybind conventions across your resource
Leverage Visual Hierarchy - Use icons, colors, and positioning to create clear visual hierarchy and importance levels
Handle State Management Properly - Always hide text UI when conditions change to prevent UI pollution and confusion
Test Across Resolutions - Ensure text UI displays correctly on different screen sizes and aspect ratios
Maintain Visual Consistency - Use consistent styling, colors, and positioning patterns throughout your resource
Implement Context Awareness - Show relevant information based on player state, location, and current activities
Optimize Update Frequency - Use appropriate update intervals to balance responsiveness with performance
Use Server-Side Strategically - Leverage server-side text UI for administrative tools, events, and player-specific content
Implement Priority Systems - Use priority-based systems to manage multiple text UI contexts and prevent conflicts
Provide Accessibility Options - Consider colorblind users and provide high contrast options when needed
Troubleshooting
Text UI Not Showing
Check that the text parameter is provided and not empty
Verify B2Lib is properly initialized
Check console for error messages from B2Lib.Debug
Ensure no other modal dialogs are blocking the display
Text UI Not Hiding
Verify hideTextUI() is being called correctly
Check that the text UI was successfully shown first
Ensure no other scripts are showing text UI simultaneously
Test with manual hideTextUI() calls
Positioning Issues
Check that position values are valid strings
Test with default position first
Verify screen resolution compatibility
Check for CSS conflicts in custom styling
Performance Issues
Avoid showing/hiding text UI too frequently
Use reasonable update intervals in loops
Clean up event handlers when no longer needed
Limit the number of active text UI elements
Last updated