StarterGui

Lo StarterGui è un servizio in Roblox che contiene elementi GUI (Interfaccia Grafica Utente) che vengono clonati nel PlayerGui di ogni giocatore quando si uniscono al gioco.

Gli script posizionati nello StarterGui controllano tipicamente gli elementi dell'interfaccia utente, come pulsanti, menu e altri elementi con cui i giocatori interagiscono durante il gioco.

Esempio di StarterGui

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

Se hai trovato utile questo tutorial e desideri supportare il mio lavoro, considera di offrirmi un caffè.

Grazie mille per il tuo supporto!

Offrimi un caffè