ðŸĨ‡UIService

Service for creating in-game UI.

Functions

createProgressBar(maxProgress: number): 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:

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

Creates a 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, Teams, or strings.

Example usage of a Leaderboard that displays strings:

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): TextLabel

Creates a TextLabel that is displayed in-world.

Example usage:

-- 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

Last updated