ScreenGui

ScreenGui 是 Roblox 中用于在玩家屏幕上显示 2D 用户界面元素的容器。它提供了基本的控制和信息。

** 必须附加到 PlayerGui 才能可见。使用 StarterGui 确保其在玩家加入时克隆到每个玩家的 PlayerGui 中。
local screenGui = Instance.new("ScreenGui")
screenGui.Parent = game.Players.LocalPlayer: WaitForChild("PlayerGui")

ScreenGui 属性

TypesDetails
ClipToDeviceSafeArea将内容裁剪到设备的安全区域。
DisplayOrder控制 ScreenGuis 的 Z-索引顺序,值越大渲染越靠上。
IgnoreGuiInset决定 ScreenGui 是否会溢出到 Roblox 的核心 UI 元素中。
ScreenInsets定义屏幕上的显示区域。

CoreUISafeInsets (核心 UI 安全区域)

CoreUISafeInsets将 UI 元素保持在核心 UI 安全区域内,避免顶栏按钮和屏幕切口(默认)。
None没有安全区域限制;UI 元素可能会被核心 UI 或设备切口遮挡,适用于非交互式内容。
TopbarSafeInsets确保 UI 元素保持在最左侧的 Roblox 控件和设备安全区域之间,动态调整以避免碰撞。
DeviceSafeInsets为整个设备的安全区域应用内边距,避免任何屏幕切口或凹槽。
Image 1
Roblox Studio
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "Display_CoreUISafeInsets"
screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
screenGui.ScreenInsets = Enum.ScreenInsets.CoreUISafeInsets

local frame = Instance.new("Frame")
frame.Size = UDim2.new(1, 0, 1, 0)
frame.Position = UDim2.new(0, 0, 0, 0)
frame.BackgroundTransparency = 0.5
frame.BackgroundColor3 = Color3.fromRGB(255, 0, 0)  -- Red for CoreUISafeInsets
frame.Parent = screenGui

local label = Instance.new("TextLabel")
label.Text = "CoreUISafeInsets"
label.BackgroundTransparency = 0
label.BackgroundColor3 = Color3.fromRGB(255, 255, 255)  -- White background
label.TextColor3 = Color3.fromRGB(0, 0, 0)  -- Black text
label.Size = UDim2.new(0.3, 0, 0.1, 0)
label.Position = UDim2.new(0.35, 0, 0.45, 0)
label.Parent = frame
Image 1
Roblox Studio
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "Display_None"
screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
screenGui.ScreenInsets = Enum.ScreenInsets.None

local frame = Instance.new("Frame")
frame.Size = UDim2.new(1, 0, 1, 0)
frame.Position = UDim2.new(0, 0, 0, 0)
frame.BackgroundTransparency = 0.5
frame.BackgroundColor3 = Color3.fromRGB(0, 255, 0)  -- Green for None
frame.Parent = screenGui

local label = Instance.new("TextLabel")
label.Text = "None"
label.BackgroundTransparency = 0
label.BackgroundColor3 = Color3.fromRGB(255, 255, 255)  -- White background
label.TextColor3 = Color3.fromRGB(0, 0, 0)  -- Black text
label.Size = UDim2.new(0.3, 0, 0.1, 0)
label.Position = UDim2.new(0.35, 0, 0.45, 0)
label.Parent = frame
Image 1
Roblox Studio
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "Display_TopbarSafeInsets"
screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
screenGui.ScreenInsets = Enum.ScreenInsets.TopbarSafeInsets

local frame = Instance.new("Frame")
frame.Size = UDim2.new(1, 0, 1, 0)
frame.Position = UDim2.new(0, 0, 0, 0)
frame.BackgroundTransparency = 0.5
frame.BackgroundColor3 = Color3.fromRGB(0, 0, 255)  -- Blue for TopbarSafeInsets
frame.Parent = screenGui

local label = Instance.new("TextLabel")
label.Text = "TopbarSafeInsets"
label.BackgroundTransparency = 0
label.BackgroundColor3 = Color3.fromRGB(255, 255, 255)  -- White background
label.TextColor3 = Color3.fromRGB(0, 0, 0)  -- Black text
label.Size = UDim2.new(0.3, 0, 0.1, 0)
label.Position = UDim2.new(0.35, 0, 0.45, 0)
label.Parent = frame
Image 1
Roblox Studio
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "Display_DeviceSafeInsets"
screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
screenGui.ScreenInsets = Enum.ScreenInsets.DeviceSafeInsets

local frame = Instance.new("Frame")
frame.Size = UDim2.new(1, 0, 1, 0)
frame.Position = UDim2.new(0, 0, 0, 0)
frame.BackgroundTransparency = 0.5
frame.BackgroundColor3 = Color3.fromRGB(255, 255, 0)  -- Yellow for DeviceSafeInsets
frame.Parent = screenGui

local label = Instance.new("TextLabel")
label.Text = "DeviceSafeInsets"
label.BackgroundTransparency = 0
label.BackgroundColor3 = Color3.fromRGB(255, 255, 255)  -- White background
label.TextColor3 = Color3.fromRGB(0, 0, 0)  -- Black text
label.Size = UDim2.new(0.3, 0, 0.1, 0)
label.Position = UDim2.new(0.35, 0, 0.45, 0)
label.Parent = frame