学ぶ
エンジンクラス
GuiObject
作成できません
閲覧できません

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。


概要
方法
TweenPosition(endPosition: UDim2,easingDirection: Enum.EasingDirection,easingStyle: Enum.EasingStyle,time: number,override: boolean,callback: function):boolean
非推奨
TweenSize(endSize: UDim2,easingDirection: Enum.EasingDirection,easingStyle: Enum.EasingStyle,time: number,override: boolean,callback: function):boolean
非推奨
TweenSizeAndPosition(endSize: UDim2,endPosition: UDim2,easingDirection: Enum.EasingDirection,easingStyle: Enum.EasingStyle,time: number,override: boolean,callback: function):boolean
非推奨
継承されたメンバー
継承者

APIリファレンス
プロパティ
Active
並列読み取り
機能: UI
GuiObject.Active:boolean
コードサンプル
テキストボタンのアクティブデバウンス
-- このLocalScriptをTextButton(またはImageButton)の中に配置します
local textButton = script.Parent
textButton.Text = "クリックしてね"
textButton.Active = true
local function onActivated()
-- これはデバウンスとして機能します
textButton.Active = false
-- 5からカウントダウンします
for i = 5, 1, -1 do
textButton.Text = "残り時間: " .. i
task.wait(1)
end
textButton.Text = "クリックしてね"
textButton.Active = true
end
textButton.Activated:Connect(onActivated)

AnchorPoint
並列読み取り
機能: UI
GuiObject.AnchorPoint:Vector2
コードサンプル
アンカーポイントデモ
local guiObject = script.Parent
while true do
-- 左上
guiObject.AnchorPoint = Vector2.new(0, 0)
guiObject.Position = UDim2.new(0, 0, 0, 0)
task.wait(1)
-- 上
guiObject.AnchorPoint = Vector2.new(0.5, 0)
guiObject.Position = UDim2.new(0.5, 0, 0, 0)
task.wait(1)
-- 右上
guiObject.AnchorPoint = Vector2.new(1, 0)
guiObject.Position = UDim2.new(1, 0, 0, 0)
task.wait(1)
-- 左
guiObject.AnchorPoint = Vector2.new(0, 0.5)
guiObject.Position = UDim2.new(0, 0, 0.5, 0)
task.wait(1)
-- 真ん中
guiObject.AnchorPoint = Vector2.new(0.5, 0.5)
guiObject.Position = UDim2.new(0.5, 0, 0.5, 0)
task.wait(1)
-- 右
guiObject.AnchorPoint = Vector2.new(1, 0.5)
guiObject.Position = UDim2.new(1, 0, 0.5, 0)
task.wait(1)
-- 左下
guiObject.AnchorPoint = Vector2.new(0, 1)
guiObject.Position = UDim2.new(0, 0, 1, 0)
task.wait(1)
-- 下
guiObject.AnchorPoint = Vector2.new(0.5, 1)
guiObject.Position = UDim2.new(0.5, 0, 1, 0)
task.wait(1)
-- 右下
guiObject.AnchorPoint = Vector2.new(1, 1)
guiObject.Position = UDim2.new(1, 0, 1, 0)
task.wait(1)
end

AutomaticSize
並列読み取り
機能: UI
GuiObject.AutomaticSize:Enum.AutomaticSize
コードサンプル
ScreenGui内のローカルスクリプト
-- 出力するテキストラベル/フォント/サイズの配列
local labelArray = {
{ text = "Lorem", font = Enum.Font.Creepster, size = 50 },
{ text = "ipsum", font = Enum.Font.IndieFlower, size = 35 },
{ text = "dolor", font = Enum.Font.Antique, size = 55 },
{ text = "sit", font = Enum.Font.SpecialElite, size = 65 },
{ text = "amet", font = Enum.Font.FredokaOne, size = 40 },
}
-- 自動的にサイズ調整される親フレームを作成
local parentFrame = Instance.new("Frame")
parentFrame.AutomaticSize = Enum.AutomaticSize.XY
parentFrame.BackgroundColor3 = Color3.fromRGB(90, 90, 90)
parentFrame.Size = UDim2.fromOffset(25, 100)
parentFrame.Position = UDim2.fromScale(0.1, 0.1)
parentFrame.Parent = script.Parent
-- リストレイアウトを追加
local listLayout = Instance.new("UIListLayout")
listLayout.Padding = UDim.new(0, 5)
listLayout.Parent = parentFrame
-- 視覚的美しさのために角を丸くし、パディングを設定
local roundedCornerParent = Instance.new("UICorner")
roundedCornerParent.Parent = parentFrame
local uiPaddingParent = Instance.new("UIPadding")
uiPaddingParent.PaddingTop = UDim.new(0, 5)
uiPaddingParent.PaddingLeft = UDim.new(0, 5)
uiPaddingParent.PaddingRight = UDim.new(0, 5)
uiPaddingParent.PaddingBottom = UDim.new(0, 5)
uiPaddingParent.Parent = parentFrame
for i = 1, #labelArray do
-- 配列から自動的にサイズ調整されるテキストラベルを作成
local childLabel = Instance.new("TextLabel")
childLabel.AutomaticSize = Enum.AutomaticSize.XY
childLabel.Size = UDim2.fromOffset(75, 15)
childLabel.Text = labelArray[i]["text"]
childLabel.Font = labelArray[i]["font"]
childLabel.TextSize = labelArray[i]["size"]
childLabel.TextColor3 = Color3.new(1, 1, 1)
childLabel.Parent = parentFrame
-- 視覚的美しさ
local roundedCorner = Instance.new("UICorner")
roundedCorner.Parent = childLabel
local uiPadding = Instance.new("UIPadding")
uiPadding.PaddingTop = UDim.new(0, 5)
uiPadding.PaddingLeft = UDim.new(0, 5)
uiPadding.PaddingRight = UDim.new(0, 5)
uiPadding.PaddingBottom = UDim.new(0, 5)
uiPadding.Parent = childLabel
task.wait(2)
end

BackgroundColor
非推奨

BackgroundColor3
並列読み取り
機能: UI
GuiObject.BackgroundColor3:Color3
コードサンプル
レインボーフレーム
-- このコードをフレーム内のLocalScriptに入れてください
local frame = script.Parent
while true do
for hue = 0, 255, 4 do
-- HSV = 色相、彩度、値
-- 0から1まで繰り返しループすると、虹ができます!
frame.BorderColor3 = Color3.fromHSV(hue / 256, 1, 1)
frame.BackgroundColor3 = Color3.fromHSV(hue / 256, 0.5, 0.8)
task.wait()
end
end

BackgroundTransparency
並列読み取り
機能: UI
GuiObject.BackgroundTransparency:number

BorderColor
非推奨

BorderColor3
並列読み取り
機能: UI
GuiObject.BorderColor3:Color3
コードサンプル
ボタンハイライト
-- GuiObjectの中に置いてください。できればImageButton/TextButtonが望ましいです。
local button = script.Parent
local function onEnter()
button.BorderSizePixel = 2
button.BorderColor3 = Color3.new(1, 1, 0) -- 黄色
end
local function onLeave()
button.BorderSizePixel = 1
button.BorderColor3 = Color3.new(0, 0, 0) -- 黒
end
-- イベントを接続します
button.MouseEnter:Connect(onEnter)
button.MouseLeave:Connect(onLeave)
-- デフォルトの状態は「ホバーされていない」です
onLeave()

BorderMode
並列読み取り
機能: UI
GuiObject.BorderMode:Enum.BorderMode

BorderSizePixel
並列読み取り
機能: UI
GuiObject.BorderSizePixel:number
コードサンプル
ボタンハイライト
-- GuiObjectの中に置いてください。できればImageButton/TextButtonが望ましいです。
local button = script.Parent
local function onEnter()
button.BorderSizePixel = 2
button.BorderColor3 = Color3.new(1, 1, 0) -- 黄色
end
local function onLeave()
button.BorderSizePixel = 1
button.BorderColor3 = Color3.new(0, 0, 0) -- 黒
end
-- イベントを接続します
button.MouseEnter:Connect(onEnter)
button.MouseLeave:Connect(onLeave)
-- デフォルトの状態は「ホバーされていない」です
onLeave()

ClipsDescendants
並列読み取り
機能: UI
GuiObject.ClipsDescendants:boolean

Draggable
非推奨

GuiState
読み取り専用
複製されていません
並列読み取り
機能: UI
GuiObject.GuiState:Enum.GuiState

InputSink
並列読み取り
機能: UI
GuiObject.InputSink:Enum.InputSink

Interactable
並列読み取り
機能: UI
GuiObject.Interactable:boolean

LayoutOrder
並列読み取り
機能: UI
GuiObject.LayoutOrder:number

NextSelectionDown
並列読み取り
機能: UI
GuiObject.NextSelectionDown:GuiObject
コードサンプル
ゲームパッド選択グリッドの作成
-- 以下のコードを使用して、ゲームパッド選択グリッドをセットアップします
local container = script.Parent:FindFirstChild("Container")
local grid = container:GetChildren()
local rowSize = container:FindFirstChild("UIGridLayout").FillDirectionMaxCells
for _, gui in pairs(grid) do
if gui:IsA("GuiObject") then
local pos = gui.Name
-- 左の端
gui.NextSelectionLeft = container:FindFirstChild(pos - 1)
-- 右の端
gui.NextSelectionRight = container:FindFirstChild(pos + 1)
-- 上
gui.NextSelectionUp = container:FindFirstChild(pos - rowSize)
-- 下
gui.NextSelectionDown = container:FindFirstChild(pos + rowSize)
end
end
-- 以下のコードを使用してゲームパッド選択グリッドをテストします
local GuiService = game:GetService("GuiService")
local UserInputService = game:GetService("UserInputService")
GuiService.SelectedObject = container:FindFirstChild("1")
function updateSelection(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
local key = input.KeyCode
local selectedObject = GuiService.SelectedObject
if not selectedObject then
return
end
if key == Enum.KeyCode.Up then
if not selectedObject.NextSelectionUp then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Down then
if not selectedObject.NextSelectionDown then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Left then
if not selectedObject.NextSelectionLeft then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Right then
if not selectedObject.NextSelectionRight then
GuiService.SelectedObject = selectedObject
end
end
end
end
UserInputService.InputBegan:Connect(updateSelection)

NextSelectionLeft
並列読み取り
機能: UI
GuiObject.NextSelectionLeft:GuiObject
コードサンプル
ゲームパッド選択グリッドの作成
-- 以下のコードを使用して、ゲームパッド選択グリッドをセットアップします
local container = script.Parent:FindFirstChild("Container")
local grid = container:GetChildren()
local rowSize = container:FindFirstChild("UIGridLayout").FillDirectionMaxCells
for _, gui in pairs(grid) do
if gui:IsA("GuiObject") then
local pos = gui.Name
-- 左の端
gui.NextSelectionLeft = container:FindFirstChild(pos - 1)
-- 右の端
gui.NextSelectionRight = container:FindFirstChild(pos + 1)
-- 上
gui.NextSelectionUp = container:FindFirstChild(pos - rowSize)
-- 下
gui.NextSelectionDown = container:FindFirstChild(pos + rowSize)
end
end
-- 以下のコードを使用してゲームパッド選択グリッドをテストします
local GuiService = game:GetService("GuiService")
local UserInputService = game:GetService("UserInputService")
GuiService.SelectedObject = container:FindFirstChild("1")
function updateSelection(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
local key = input.KeyCode
local selectedObject = GuiService.SelectedObject
if not selectedObject then
return
end
if key == Enum.KeyCode.Up then
if not selectedObject.NextSelectionUp then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Down then
if not selectedObject.NextSelectionDown then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Left then
if not selectedObject.NextSelectionLeft then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Right then
if not selectedObject.NextSelectionRight then
GuiService.SelectedObject = selectedObject
end
end
end
end
UserInputService.InputBegan:Connect(updateSelection)

NextSelectionRight
並列読み取り
機能: UI
GuiObject.NextSelectionRight:GuiObject
コードサンプル
ゲームパッド選択グリッドの作成
-- 以下のコードを使用して、ゲームパッド選択グリッドをセットアップします
local container = script.Parent:FindFirstChild("Container")
local grid = container:GetChildren()
local rowSize = container:FindFirstChild("UIGridLayout").FillDirectionMaxCells
for _, gui in pairs(grid) do
if gui:IsA("GuiObject") then
local pos = gui.Name
-- 左の端
gui.NextSelectionLeft = container:FindFirstChild(pos - 1)
-- 右の端
gui.NextSelectionRight = container:FindFirstChild(pos + 1)
-- 上
gui.NextSelectionUp = container:FindFirstChild(pos - rowSize)
-- 下
gui.NextSelectionDown = container:FindFirstChild(pos + rowSize)
end
end
-- 以下のコードを使用してゲームパッド選択グリッドをテストします
local GuiService = game:GetService("GuiService")
local UserInputService = game:GetService("UserInputService")
GuiService.SelectedObject = container:FindFirstChild("1")
function updateSelection(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
local key = input.KeyCode
local selectedObject = GuiService.SelectedObject
if not selectedObject then
return
end
if key == Enum.KeyCode.Up then
if not selectedObject.NextSelectionUp then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Down then
if not selectedObject.NextSelectionDown then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Left then
if not selectedObject.NextSelectionLeft then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Right then
if not selectedObject.NextSelectionRight then
GuiService.SelectedObject = selectedObject
end
end
end
end
UserInputService.InputBegan:Connect(updateSelection)

NextSelectionUp
並列読み取り
機能: UI
GuiObject.NextSelectionUp:GuiObject
コードサンプル
ゲームパッド選択グリッドの作成
-- 以下のコードを使用して、ゲームパッド選択グリッドをセットアップします
local container = script.Parent:FindFirstChild("Container")
local grid = container:GetChildren()
local rowSize = container:FindFirstChild("UIGridLayout").FillDirectionMaxCells
for _, gui in pairs(grid) do
if gui:IsA("GuiObject") then
local pos = gui.Name
-- 左の端
gui.NextSelectionLeft = container:FindFirstChild(pos - 1)
-- 右の端
gui.NextSelectionRight = container:FindFirstChild(pos + 1)
-- 上
gui.NextSelectionUp = container:FindFirstChild(pos - rowSize)
-- 下
gui.NextSelectionDown = container:FindFirstChild(pos + rowSize)
end
end
-- 以下のコードを使用してゲームパッド選択グリッドをテストします
local GuiService = game:GetService("GuiService")
local UserInputService = game:GetService("UserInputService")
GuiService.SelectedObject = container:FindFirstChild("1")
function updateSelection(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
local key = input.KeyCode
local selectedObject = GuiService.SelectedObject
if not selectedObject then
return
end
if key == Enum.KeyCode.Up then
if not selectedObject.NextSelectionUp then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Down then
if not selectedObject.NextSelectionDown then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Left then
if not selectedObject.NextSelectionLeft then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Right then
if not selectedObject.NextSelectionRight then
GuiService.SelectedObject = selectedObject
end
end
end
end
UserInputService.InputBegan:Connect(updateSelection)

Position
並列読み取り
機能: UI
GuiObject.Position:UDim2

Rotation
並列読み取り
機能: UI
GuiObject.Rotation:number

Selectable
並列読み取り
機能: UI
GuiObject.Selectable:boolean
コードサンプル
テキストボックス選択の制限
local GuiService = game:GetService("GuiService")
local textBox = script.Parent
local function gainFocus()
textBox.Selectable = true
GuiService.SelectedObject = textBox
end
local function loseFocus(_enterPressed, _inputObject)
GuiService.SelectedObject = nil
textBox.Selectable = false
end
-- FocusLostおよびFocusGainedイベントは、textBoxが
-- TextBox型であるために発火します
textBox.Focused:Connect(gainFocus)
textBox.FocusLost:Connect(loseFocus)

SelectionImageObject
並列読み取り
機能: UI
GuiObject.SelectionImageObject:GuiObject

SelectionOrder
並列読み取り
機能: UI
GuiObject.SelectionOrder:number

Size
並列読み取り
機能: UI
GuiObject.Size:UDim2
コードサンプル
ヘルスバー
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- スクリプトをフレーム内のフレームに
-- 親付けられたLocalScriptに貼り付ける
local frame = script.Parent
local container = frame.Parent
container.BackgroundColor3 = Color3.new(0, 0, 0) -- 黒
-- この関数はヒューマノイドのヘルスが変化したときに呼ばれます
local function onHealthChanged()
local human = player.Character.Humanoid
local percent = human.Health / human.MaxHealth
-- 内側のバーのサイズを変更する
frame.Size = UDim2.new(percent, 0, 1, 0)
-- ヘルスバーの色を変更する
if percent < 0.1 then
frame.BackgroundColor3 = Color3.new(1, 0, 0) -- 黒
elseif percent < 0.4 then
frame.BackgroundColor3 = Color3.new(1, 1, 0) -- 黄色
else
frame.BackgroundColor3 = Color3.new(0, 1, 0) -- 緑
end
end
-- この関数はプレーヤーがスポーンしたときに呼ばれます
local function onCharacterAdded(character)
local human = character:WaitForChild("Humanoid")
-- パターン: 現在一度更新し、その後ヘルスが変わるたびに
human.HealthChanged:Connect(onHealthChanged)
onHealthChanged()
end
-- スポーンリスナーを接続; すでにスポーンしている場合は呼び出す
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then
onCharacterAdded(player.Character)
end

SizeConstraint
並列読み取り
機能: UI
GuiObject.SizeConstraint:Enum.SizeConstraint

Transparency
非推奨

Visible
並列読み取り
機能: UI
GuiObject.Visible:boolean
コードサンプル
UIウィンドウ
local gui = script.Parent
local window = gui:WaitForChild("Window")
local toggleButton = gui:WaitForChild("ToggleWindow")
local closeButton = window:WaitForChild("Close")
local function toggleWindowVisbility()
-- `not` キーワードを使用してブール値を反転させる
window.Visible = not window.Visible
end
toggleButton.Activated:Connect(toggleWindowVisbility)
closeButton.Activated:Connect(toggleWindowVisbility)

ZIndex
並列読み取り
機能: UI
GuiObject.ZIndex:number

方法
TweenPosition
非推奨

TweenSize
非推奨

TweenSizeAndPosition
非推奨

イベント
DragBegin
非推奨

DragStopped
非推奨

InputBegan
機能: UI
GuiObject.InputBegan(input:InputObject):RBXScriptSignal
パラメータ
コードサンプル
GuiObject の入力開始の追跡
-- InputBegan イベントを使用するには、GuiObject を指定する必要があります
local gui = script.Parent
-- 様々なタイプのユーザー入力に対して複数の使用ケースを提供するサンプル関数
local function inputBegan(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
print("キーが押されています! キー:", input.KeyCode)
elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
print("左マウスボタンが押されました。位置:", input.Position)
elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
print("右マウスボタンが押されました。位置:", input.Position)
elseif input.UserInputType == Enum.UserInputType.Touch then
print("タッチスクリーン入力が開始されました。位置:", input.Position)
elseif input.UserInputType == Enum.UserInputType.Gamepad1 then
print("ゲームパッドのボタンが押されています! ボタン:", input.KeyCode)
end
end
gui.InputBegan:Connect(inputBegan)

InputChanged
機能: UI
GuiObject.InputChanged(input:InputObject):RBXScriptSignal
パラメータ
コードサンプル
GuiObject 入力変更デモ
local UserInputService = game:GetService("UserInputService")
local gui = script.Parent
local function printMovement(input)
print("位置:", input.Position)
print("移動デルタ:", input.Delta)
end
local function inputChanged(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
print("マウスが移動しました!")
printMovement(input)
elseif input.UserInputType == Enum.UserInputType.MouseWheel then
print("マウスホイールがスクロールされました!")
print("ホイール移動:", input.Position.Z)
elseif input.UserInputType == Enum.UserInputType.Gamepad1 then
if input.KeyCode == Enum.KeyCode.Thumbstick1 then
print("左のスティックが移動しました!")
printMovement(input)
elseif input.KeyCode == Enum.KeyCode.Thumbstick2 then
print("右のスティックが移動しました!")
printMovement(input)
elseif input.KeyCode == Enum.KeyCode.ButtonL2 then
print("左トリガーにかかる圧力が変わりました!")
print("圧力:", input.Position.Z)
elseif input.KeyCode == Enum.KeyCode.ButtonR2 then
print("右トリガーにかかる圧力が変わりました!")
print("圧力:", input.Position.Z)
end
elseif input.UserInputType == Enum.UserInputType.Touch then
print("ユーザーの指が画面で移動しています!")
printMovement(input)
elseif input.UserInputType == Enum.UserInputType.Gyro then
local _rotInput, rotCFrame = UserInputService:GetDeviceRotation()
local rotX, rotY, rotZ = rotCFrame:toEulerAnglesXYZ()
local rot = Vector3.new(math.deg(rotX), math.deg(rotY), math.deg(rotZ))
print("ユーザーのモバイルデバイスの向きが変わりました!")
print("位置", rotCFrame.p)
print("回転:", rot)
elseif input.UserInputType == Enum.UserInputType.Accelerometer then
print("ユーザーのモバイルデバイスの加速度が変わりました!")
printMovement(input)
end
end
gui.InputChanged:Connect(inputChanged)

InputEnded
機能: UI
GuiObject.InputEnded(input:InputObject):RBXScriptSignal
パラメータ
コードサンプル
GuiObjectの入力終了を追跡する
-- InputChangedイベントを使用するには、GuiObjectを指定する必要があります。
local gui = script.Parent
-- 様々なタイプのユーザー入力に対して複数の使用ケースを提供するサンプル関数
local function inputEnded(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
print("キーが放 released されました! キー:", input.KeyCode)
elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
print("左マウスボタンが at", input.Position, "に放 released されました")
elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
print("右マウスボタンが at", input.Position, "に放 released されました")
elseif input.UserInputType == Enum.UserInputType.Touch then
print("タッチスクリーン入力が at", input.Position, "に放 released されました")
elseif input.UserInputType == Enum.UserInputType.Gamepad1 then
print("ゲームパッドのボタンが放 released されました! ボタン:", input.KeyCode)
end
end
gui.InputEnded:Connect(inputEnded)

MouseEnter
機能: UI
GuiObject.MouseEnter(
パラメータ
コードサンプル
GuiObjectにマウスが入った位置を表示
local guiObject = script.Parent
guiObject.MouseEnter:Connect(function(x, y)
print("ユーザーのマウスカーソルがGuiObjectの位置に入った", x, ",", y)
end)

MouseLeave
機能: UI
GuiObject.MouseLeave(
パラメータ

MouseMoved
機能: UI
GuiObject.MouseMoved(
パラメータ

MouseWheelBackward
機能: UI
GuiObject.MouseWheelBackward(
パラメータ

MouseWheelForward
機能: UI
GuiObject.MouseWheelForward(
パラメータ

SelectionGained
機能: UI
GuiObject.SelectionGained():RBXScriptSignal
コードサンプル
GUI選択の獲得処理
local guiObject = script.Parent
local function selectionGained()
print("ユーザーはゲームパッドでこのボタンを選択しました。")
end
guiObject.SelectionGained:Connect(selectionGained)

SelectionLost
機能: UI
GuiObject.SelectionLost():RBXScriptSignal
コードサンプル
GUI 選択の喪失の処理
local guiObject = script.Parent
local function selectionLost()
print("ユーザーはもはやゲームパッドでこれを選択していません。")
end
guiObject.SelectionLost:Connect(selectionLost)

TouchLongPress
機能: UI
GuiObject.TouchLongPress(
touchPositions:{any}, state:Enum.UserInputState
パラメータ
touchPositions:{any}
コードサンプル
タッチ長押しでUI要素を移動する
local frame = script.Parent
frame.Active = true
local dragging = false
local basePosition
local startTouchPosition
local borderColor3
local backgroundColor3
local function onTouchLongPress(touchPositions, state)
if state == Enum.UserInputState.Begin and not dragging then
-- ドラッグを開始
dragging = true
basePosition = frame.Position
startTouchPosition = touchPositions[1]
-- ドラッグ中であることを示すためにフレームの色を変更
borderColor3 = frame.BorderColor3
backgroundColor3 = frame.BackgroundColor3
frame.BorderColor3 = Color3.new(1, 1, 1) -- 白
frame.BackgroundColor3 = Color3.new(0, 0, 1) -- 青
elseif state == Enum.UserInputState.Change then
local touchPosition = touchPositions[1]
local deltaPosition =
UDim2.new(0, touchPosition.X - startTouchPosition.X, 0, touchPosition.Y - startTouchPosition.Y)
frame.Position = basePosition + deltaPosition
elseif state == Enum.UserInputState.End and dragging then
-- ドラッグを停止
dragging = false
frame.BorderColor3 = borderColor3
frame.BackgroundColor3 = backgroundColor3
end
end
frame.TouchLongPress:Connect(onTouchLongPress)

TouchPan
機能: UI
GuiObject.TouchPan(
touchPositions:{any}, totalTranslation:Vector2, velocity:Vector2, state:Enum.UserInputState
パラメータ
touchPositions:{any}
totalTranslation:Vector2
velocity:Vector2
コードサンプル
パンニング UI 要素
local innerFrame = script.Parent
local outerFrame = innerFrame.Parent
outerFrame.BackgroundTransparency = 0.75
outerFrame.Active = true
outerFrame.Size = UDim2.new(1, 0, 1, 0)
outerFrame.Position = UDim2.new(0, 0, 0, 0)
outerFrame.AnchorPoint = Vector2.new(0, 0)
outerFrame.ClipsDescendants = true
local dragging = false
local basePosition
local function onTouchPan(_touchPositions, totalTranslation, _velocity, state)
if state == Enum.UserInputState.Begin and not dragging then
dragging = true
basePosition = innerFrame.Position
outerFrame.BackgroundTransparency = 0.25
elseif state == Enum.UserInputState.Change then
innerFrame.Position = basePosition + UDim2.new(0, totalTranslation.X, 0, totalTranslation.Y)
elseif state == Enum.UserInputState.End and dragging then
dragging = false
outerFrame.BackgroundTransparency = 0.75
end
end
outerFrame.TouchPan:Connect(onTouchPan)

TouchPinch
機能: UI
GuiObject.TouchPinch(
touchPositions:{any}, scale:number, velocity:number, state:Enum.UserInputState
パラメータ
touchPositions:{any}
scale:number
velocity:number
コードサンプル
ピンチ/プル スケーリング
local innerFrame = script.Parent
local outerFrame = innerFrame.Parent
outerFrame.BackgroundTransparency = 0.75
outerFrame.Active = true
outerFrame.Size = UDim2.new(1, 0, 1, 0)
outerFrame.Position = UDim2.new(0, 0, 0, 0)
outerFrame.AnchorPoint = Vector2.new(0, 0)
outerFrame.ClipsDescendants = true
local dragging = false
local uiScale = Instance.new("UIScale")
uiScale.Parent = innerFrame
local baseScale
local function onTouchPinch(_touchPositions, scale, _velocity, state)
if state == Enum.UserInputState.Begin and not dragging then
dragging = true
baseScale = uiScale.Scale
outerFrame.BackgroundTransparency = 0.25
elseif state == Enum.UserInputState.Change then
uiScale.Scale = baseScale * scale -- ここでの掛け算に注意
elseif state == Enum.UserInputState.End and dragging then
dragging = false
outerFrame.BackgroundTransparency = 0.75
end
end
outerFrame.TouchPinch:Connect(onTouchPinch)

TouchRotate
機能: UI
GuiObject.TouchRotate(
touchPositions:{any}, rotation:number, velocity:number, state:Enum.UserInputState
パラメータ
touchPositions:{any}
rotation:number
velocity:number
コードサンプル
タッチ回転
local innerFrame = script.Parent
local outerFrame = innerFrame.Parent
outerFrame.BackgroundTransparency = 0.75
outerFrame.Active = true
outerFrame.Size = UDim2.new(1, 0, 1, 0)
outerFrame.Position = UDim2.new(0, 0, 0, 0)
outerFrame.AnchorPoint = Vector2.new(0, 0)
outerFrame.ClipsDescendants = true
local dragging = false
local baseRotation = innerFrame.Rotation
local function onTouchRotate(_touchPositions, rotation, _velocity, state)
if state == Enum.UserInputState.Begin and not dragging then
dragging = true
baseRotation = innerFrame.Rotation
outerFrame.BackgroundTransparency = 0.25
elseif state == Enum.UserInputState.Change then
innerFrame.Rotation = baseRotation + rotation
elseif state == Enum.UserInputState.End and dragging then
dragging = false
outerFrame.BackgroundTransparency = 0.75
end
end
outerFrame.TouchRotate:Connect(onTouchRotate)

TouchSwipe
機能: UI
GuiObject.TouchSwipe(
swipeDirection:Enum.SwipeDirection, numberOfTouches:number
パラメータ
swipeDirection:Enum.SwipeDirection
numberOfTouches:number
コードサンプル
バウンスするカラー ピッカー
local frame = script.Parent
frame.Active = true
-- スワイプが成功した時のフレームのバウンス距離
local BOUNCE_DISTANCE = 50
-- フレームの現在の状態
local basePosition = frame.Position
local hue = 0
local saturation = 128
local function updateColor()
frame.BackgroundColor3 = Color3.fromHSV(hue / 256, saturation / 256, 1)
end
local function onTouchSwipe(swipeDir, _touchCount)
-- スワイプ方向に基づいてBackgroundColor3を変更
local deltaPos
if swipeDir == Enum.SwipeDirection.Right then
deltaPos = UDim2.new(0, BOUNCE_DISTANCE, 0, 0)
hue = (hue + 16) % 255
elseif swipeDir == Enum.SwipeDirection.Left then
deltaPos = UDim2.new(0, -BOUNCE_DISTANCE, 0, 0)
hue = (hue - 16) % 255
elseif swipeDir == Enum.SwipeDirection.Up then
deltaPos = UDim2.new(0, 0, 0, -BOUNCE_DISTANCE)
saturation = (saturation + 16) % 255
elseif swipeDir == Enum.SwipeDirection.Down then
deltaPos = UDim2.new(0, 0, 0, BOUNCE_DISTANCE)
saturation = (saturation - 16) % 255
else
deltaPos = UDim2.new()
end
-- 色を更新し、フレームを少しバウンスさせる
updateColor()
frame.Position = basePosition + deltaPos
frame:TweenPosition(basePosition, Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 0.7, true)
end
frame.TouchSwipe:Connect(onTouchSwipe)
updateColor()

TouchTap
機能: UI
GuiObject.TouchTap(touchPositions:{any}):RBXScriptSignal
パラメータ
touchPositions:{any}
コードサンプル
透過トグルをタップ
local frame = script.Parent
frame.Active = true
local function onTouchTap()
-- 背景の透過を切り替えます
if frame.BackgroundTransparency > 0 then
frame.BackgroundTransparency = 0
else
frame.BackgroundTransparency = 0.75
end
end
frame.TouchTap:Connect(onTouchTap)

©2026 Roblox Corporation。Roblox(ロブロックス)、RobloxロゴおよびPowering Imaginationは、米国並びにその他の国における登録商標および非登録商標です。