Empty
Empty
Empty
StarterGuiは、プレイヤーがゲームに参加する際にPlayerGuiにクローンされるGUI (グラフィカルユーザーインターフェイス)要素を保持するRobloxのサービスです。
Empty
Empty
Empty
StarterGuiに配置されたスクリプトは、通常、ゲームプレイ中にプレイヤーが操作するUI要素、例えばボタン、メニュー、その他のインターフェイス要素を制御します。
StarterGuiの例
Empty
Empty
Empty
-- 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()
Roblox Studio