StarterGui

The StarterGui is a service in Roblox that holds GUI (Graphical User Interface) elements that are cloned into each player's PlayerGui when they join the game.

Scripts placed in StarterGui typically control the UI elements, such as buttons, menus, and other interface elements, that players interact with during gameplay.

StarterGui Example

-- StarterGui > HealthGui > HealthScript

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

local healthGui = script.Parent
local healthBar = healthGui:WaitForChild("Frame")
local healthLabel = healthBar:WaitForChild("TextLabel")

local function updateHealth()
    local humanoid = character:FindFirstChildOfClass("Humanoid")
    if humanoid then
        local healthPercent = humanoid.Health / humanoid.MaxHealth
        healthBar.Size = UDim2.new(healthPercent, 0, 1, 0)
        healthLabel.Text = math.ceil(humanoid.Health) .. " / " .. math.ceil(humanoid.MaxHealth)
    end
end

local humanoid = character:WaitForChild("Humanoid")
humanoid.HealthChanged:Connect(updateHealth)

updateHealth()
Image 1
Image 2
Roblox Studio

If you found this tutorial helpful and would like to support my work, please consider buying me a coffee.

Thank you very much for your support!

Buy me a coffee