# UIService

### Functions

#### createProgressBar(maxProgress: number): [ProgressBar](https://docs.easy.gg/scripting/bedwars-scripting/objects/progressbar)

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](https://docs.easy.gg/scripting/bedwars-scripting/objects/leaderboard)

Creates a [Leaderboard](https://docs.easy.gg/scripting/bedwars-scripting/objects/leaderboard) that is displayed for all players. A custom game can only have one leaderboard at any given time. Leaderboards can have entries of [Players](https://docs.easy.gg/scripting/bedwars-scripting/objects/player), [Teams](https://docs.easy.gg/scripting/bedwars-scripting/objects/team), 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](https://docs.easy.gg/scripting/bedwars-scripting/objects/textlabel)

Creates a [TextLabel](https://docs.easy.gg/scripting/bedwars-scripting/objects/textlabel) 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
```
