# UIService

### Functions

#### createProgressBar(maxProgress: number): [ProgressBar](/scripting/bedwars-scripting/objects/progressbar.md)

Creates a progress bar with the given maximum progress value. By default, progress bars are displayed globally, but the list of players who are able to view the progress bar can be configured.

Example usage:

```lua
local diamondBar = UIService.createProgressBar(10)
diamondBar:setColor(Color3.fromRGB(0, 179, 179))

local emeraldBar = UIService.createProgressBar(15)
emeraldBar:setColor(Color3.fromRGB(80, 200, 120))

Events.InventoryItemAdded(function(event)
    if (event.item == ItemType.DIAMOND) then
        diamondBar:add(event.amount)
    end    
    if (event.item == ItemType.EMERALD) then
        emeraldBar:add(event.amount)
    end
end)
```

#### createLeaderboard(): [Leaderboard](/scripting/bedwars-scripting/objects/leaderboard.md)

Creates a [Leaderboard](/scripting/bedwars-scripting/objects/leaderboard.md) that is displayed for all players. A custom game can only have one leaderboard at any given time. Leaderboards can have entries of [Players](/scripting/bedwars-scripting/objects/player.md), [Teams](/scripting/bedwars-scripting/objects/team.md), or strings.

Example usage of a Leaderboard that displays strings:

```lua
local board = UIService.createLeaderboard()

board:addKey('Blue')
board:addKey('Pink')

Events.BlockPlace(function(event)
    if (event.blockType == ItemType.WOOL_PINK) then
        board:addScore('Pink', 1)
    end
    if (event.blockType == ItemType.WOOL_BLUE) then
        board:addScore('Blue', 1)
    end
end)
```

#### createTextLabel(text: string, position: [Vector3](https://create.roblox.com/docs/reference/engine/datatypes/Vector3)): [TextLabel](/scripting/bedwars-scripting/objects/textlabel.md)

Creates a [TextLabel](/scripting/bedwars-scripting/objects/textlabel.md) that is displayed in-world.

Example usage:

```lua
-- Create a text label above all Slime Blocks
local slimeBlocks = BlockService.getAllBlocks({ ItemType.SLIME_BLOCK })

for i, block in ipairs(slimeBlocks) do
    local positionAbove = block.position + Vector3.new(0, 6, 0)
    local label = UIService.createTextLabel("Gloop's House", positionAbove)

    label:setBackgroundColor(Color3.fromRGB(126, 255, 103))
    label:setBackgroundTransparency(0.2)
    label:setTextColor(Color3.fromRGB(0,0,0))
    label:setSize(UDim2.fromScale(10,2))
    label:setFont(Font.LuckiestGuy)
end
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.easy.gg/scripting/bedwars-scripting/services/uiservice.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
