Apprendre
Classe de moteur
GuiObject
Création impossible
Non navigable

*Ce contenu est traduit en utilisant l'IA (Beta) et peut contenir des erreurs. Pour consulter cette page en anglais, clique ici.


Résumé
Méthodes
TweenPosition(endPosition: UDim2,easingDirection: Enum.EasingDirection,easingStyle: Enum.EasingStyle,time: number,override: boolean,callback: function):boolean
Déprécié
TweenSize(endSize: UDim2,easingDirection: Enum.EasingDirection,easingStyle: Enum.EasingStyle,time: number,override: boolean,callback: function):boolean
Déprécié
TweenSizeAndPosition(endSize: UDim2,endPosition: UDim2,easingDirection: Enum.EasingDirection,easingStyle: Enum.EasingStyle,time: number,override: boolean,callback: function):boolean
Déprécié
Membres hérités
Hérité par

Référence API
Propriétés
Active
Lecture parallèle
Capacités : UI
GuiObject.Active:boolean
Échantillons de code
Texte Bouton Actif Debounce
-- Placez ce LocalScript à l'intérieur d'un TextButton (ou ImageButton)
local textButton = script.Parent
textButton.Text = "Cliquez sur moi"
textButton.Active = true
local function onActivated()
-- Cela agit comme un debounce
textButton.Active = false
-- Comptez à rebours depuis 5
for i = 5, 1, -1 do
textButton.Text = "Temps : " .. i
task.wait(1)
end
textButton.Text = "Cliquez sur moi"
textButton.Active = true
end
textButton.Activated:Connect(onActivated)

AnchorPoint
Lecture parallèle
Capacités : UI
GuiObject.AnchorPoint:Vector2
Échantillons de code
Démonstration du Point d'Ancrage
local guiObject = script.Parent
while true do
-- Haut à gauche
guiObject.AnchorPoint = Vector2.new(0, 0)
guiObject.Position = UDim2.new(0, 0, 0, 0)
task.wait(1)
-- Haut
guiObject.AnchorPoint = Vector2.new(0.5, 0)
guiObject.Position = UDim2.new(0.5, 0, 0, 0)
task.wait(1)
-- Haut à droite
guiObject.AnchorPoint = Vector2.new(1, 0)
guiObject.Position = UDim2.new(1, 0, 0, 0)
task.wait(1)
-- Gauche
guiObject.AnchorPoint = Vector2.new(0, 0.5)
guiObject.Position = UDim2.new(0, 0, 0.5, 0)
task.wait(1)
-- Centre exact
guiObject.AnchorPoint = Vector2.new(0.5, 0.5)
guiObject.Position = UDim2.new(0.5, 0, 0.5, 0)
task.wait(1)
-- Droite
guiObject.AnchorPoint = Vector2.new(1, 0.5)
guiObject.Position = UDim2.new(1, 0, 0.5, 0)
task.wait(1)
-- Bas à gauche
guiObject.AnchorPoint = Vector2.new(0, 1)
guiObject.Position = UDim2.new(0, 0, 1, 0)
task.wait(1)
-- Bas
guiObject.AnchorPoint = Vector2.new(0.5, 1)
guiObject.Position = UDim2.new(0.5, 0, 1, 0)
task.wait(1)
-- Bas à droite
guiObject.AnchorPoint = Vector2.new(1, 1)
guiObject.Position = UDim2.new(1, 0, 1, 0)
task.wait(1)
end

AutomaticSize
Lecture parallèle
Capacités : UI
GuiObject.AutomaticSize:Enum.AutomaticSize
Échantillons de code
LocalScript dans un ScreenGui
-- Tableau des étiquettes de texte/typos/taille à afficher
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 },
}
-- Créer un cadre parent à taille automatique
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
-- Ajouter une mise en page de liste
local listLayout = Instance.new("UIListLayout")
listLayout.Padding = UDim.new(0, 5)
listLayout.Parent = parentFrame
-- Définir des coins arrondis et un remplissage pour l'esthétique visuelle
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
-- Créer une étiquette de texte à taille automatique à partir du tableau
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
-- Esthétique visuelle
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
Déprécié

BackgroundColor3
Lecture parallèle
Capacités : UI
GuiObject.BackgroundColor3:Color3
Échantillons de code
Cadre Arc-en-ciel
-- Mettez ce code dans un LocalScript dans un Frame
local frame = script.Parent
while true do
for hue = 0, 255, 4 do
-- HSV = teinte, saturation, valeur
-- Si nous bouclons de 0 à 1 de manière répétée, nous obtenons un arc-en-ciel !
frame.BorderColor3 = Color3.fromHSV(hue / 256, 1, 1)
frame.BackgroundColor3 = Color3.fromHSV(hue / 256, 0.5, 0.8)
task.wait()
end
end

BackgroundTransparency
Lecture parallèle
Capacités : UI
GuiObject.BackgroundTransparency:number

BorderColor
Déprécié

BorderColor3
Lecture parallèle
Capacités : UI
GuiObject.BorderColor3:Color3
Échantillons de code
Mise en surbrillance du bouton
-- Mettez-moi à l'intérieur d'un GuiObject, de préférence un ImageButton/TextButton
local button = script.Parent
local function onEnter()
button.BorderSizePixel = 2
button.BorderColor3 = Color3.new(1, 1, 0) -- Jaune
end
local function onLeave()
button.BorderSizePixel = 1
button.BorderColor3 = Color3.new(0, 0, 0) -- Noir
end
-- Connecter les événements
button.MouseEnter:Connect(onEnter)
button.MouseLeave:Connect(onLeave)
-- Notre état par défaut est "non survolé"
onLeave()

BorderMode
Lecture parallèle
Capacités : UI
GuiObject.BorderMode:Enum.BorderMode

BorderSizePixel
Lecture parallèle
Capacités : UI
GuiObject.BorderSizePixel:number
Échantillons de code
Mise en surbrillance du bouton
-- Mettez-moi à l'intérieur d'un GuiObject, de préférence un ImageButton/TextButton
local button = script.Parent
local function onEnter()
button.BorderSizePixel = 2
button.BorderColor3 = Color3.new(1, 1, 0) -- Jaune
end
local function onLeave()
button.BorderSizePixel = 1
button.BorderColor3 = Color3.new(0, 0, 0) -- Noir
end
-- Connecter les événements
button.MouseEnter:Connect(onEnter)
button.MouseLeave:Connect(onLeave)
-- Notre état par défaut est "non survolé"
onLeave()

ClipsDescendants
Lecture parallèle
Capacités : UI
GuiObject.ClipsDescendants:boolean

Draggable
Déprécié

GuiState
Lecture uniquement
Non répliqué
Lecture parallèle
Capacités : UI
GuiObject.GuiState:Enum.GuiState

InputSink
Lecture parallèle
Capacités : UI
GuiObject.InputSink:Enum.InputSink

Interactable
Lecture parallèle
Capacités : UI
GuiObject.Interactable:boolean

LayoutOrder
Lecture parallèle
Capacités : UI
GuiObject.LayoutOrder:number

NextSelectionDown
Lecture parallèle
Capacités : UI
GuiObject.NextSelectionDown:GuiObject
Échantillons de code
Création d'une grille de sélection de manette
-- Configurer la grille de sélection de manette en utilisant le code ci-dessous
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
-- Bord gauche
gui.NextSelectionLeft = container:FindFirstChild(pos - 1)
-- Bord droit
gui.NextSelectionRight = container:FindFirstChild(pos + 1)
-- Au-dessus
gui.NextSelectionUp = container:FindFirstChild(pos - rowSize)
-- En dessous
gui.NextSelectionDown = container:FindFirstChild(pos + rowSize)
end
end
-- Tester la grille de sélection de manette en utilisant le code ci-dessous
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
Lecture parallèle
Capacités : UI
GuiObject.NextSelectionLeft:GuiObject
Échantillons de code
Création d'une grille de sélection de manette
-- Configurer la grille de sélection de manette en utilisant le code ci-dessous
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
-- Bord gauche
gui.NextSelectionLeft = container:FindFirstChild(pos - 1)
-- Bord droit
gui.NextSelectionRight = container:FindFirstChild(pos + 1)
-- Au-dessus
gui.NextSelectionUp = container:FindFirstChild(pos - rowSize)
-- En dessous
gui.NextSelectionDown = container:FindFirstChild(pos + rowSize)
end
end
-- Tester la grille de sélection de manette en utilisant le code ci-dessous
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
Lecture parallèle
Capacités : UI
GuiObject.NextSelectionRight:GuiObject
Échantillons de code
Création d'une grille de sélection de manette
-- Configurer la grille de sélection de manette en utilisant le code ci-dessous
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
-- Bord gauche
gui.NextSelectionLeft = container:FindFirstChild(pos - 1)
-- Bord droit
gui.NextSelectionRight = container:FindFirstChild(pos + 1)
-- Au-dessus
gui.NextSelectionUp = container:FindFirstChild(pos - rowSize)
-- En dessous
gui.NextSelectionDown = container:FindFirstChild(pos + rowSize)
end
end
-- Tester la grille de sélection de manette en utilisant le code ci-dessous
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
Lecture parallèle
Capacités : UI
GuiObject.NextSelectionUp:GuiObject
Échantillons de code
Création d'une grille de sélection de manette
-- Configurer la grille de sélection de manette en utilisant le code ci-dessous
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
-- Bord gauche
gui.NextSelectionLeft = container:FindFirstChild(pos - 1)
-- Bord droit
gui.NextSelectionRight = container:FindFirstChild(pos + 1)
-- Au-dessus
gui.NextSelectionUp = container:FindFirstChild(pos - rowSize)
-- En dessous
gui.NextSelectionDown = container:FindFirstChild(pos + rowSize)
end
end
-- Tester la grille de sélection de manette en utilisant le code ci-dessous
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
Lecture parallèle
Capacités : UI
GuiObject.Position:UDim2

Rotation
Lecture parallèle
Capacités : UI
GuiObject.Rotation:number

Selectable
Lecture parallèle
Capacités : UI
GuiObject.Selectable:boolean
Échantillons de code
Limitation de la sélection du TextBox
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
-- L'événement FocusLost et FocusGained sera déclenché parce que le textBox
-- est de type TextBox
textBox.Focused:Connect(gainFocus)
textBox.FocusLost:Connect(loseFocus)

SelectionImageObject
Lecture parallèle
Capacités : UI
GuiObject.SelectionImageObject:GuiObject

SelectionOrder
Lecture parallèle
Capacités : UI
GuiObject.SelectionOrder:number

Size
Lecture parallèle
Capacités : UI
GuiObject.Size:UDim2
Échantillons de code
Barre de Vie
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- Collez le script dans un LocalScript qui est
-- parenté à un Frame à l'intérieur d'un Frame
local frame = script.Parent
local container = frame.Parent
container.BackgroundColor3 = Color3.new(0, 0, 0) -- noir
-- Cette fonction est appelée lorsque la vie du humanoïde change
local function onHealthChanged()
local human = player.Character.Humanoid
local percent = human.Health / human.MaxHealth
-- Changez la taille de la barre intérieure
frame.Size = UDim2.new(percent, 0, 1, 0)
-- Changez la couleur de la barre de vie
if percent < 0.1 then
frame.BackgroundColor3 = Color3.new(1, 0, 0) -- rouge
elseif percent < 0.4 then
frame.BackgroundColor3 = Color3.new(1, 1, 0) -- jaune
else
frame.BackgroundColor3 = Color3.new(0, 1, 0) -- vert
end
end
-- Cette fonction est appelée lorsque le joueur apparaît
local function onCharacterAdded(character)
local human = character:WaitForChild("Humanoid")
-- Modèle : mise à jour une fois maintenant, puis chaque fois que la vie change
human.HealthChanged:Connect(onHealthChanged)
onHealthChanged()
end
-- Connectez notre écouteur de spawn ; appelez-le s'il est déjà apparu
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then
onCharacterAdded(player.Character)
end

SizeConstraint
Lecture parallèle
Capacités : UI
GuiObject.SizeConstraint:Enum.SizeConstraint

Transparency
Déprécié

Visible
Lecture parallèle
Capacités : UI
GuiObject.Visible:boolean
Échantillons de code
Fenêtre UI
local gui = script.Parent
local window = gui:WaitForChild("Window")
local toggleButton = gui:WaitForChild("ToggleWindow")
local closeButton = window:WaitForChild("Close")
local function toggleWindowVisbility()
-- Inversez un booléen en utilisant le mot-clé `not`
window.Visible = not window.Visible
end
toggleButton.Activated:Connect(toggleWindowVisbility)
closeButton.Activated:Connect(toggleWindowVisbility)

ZIndex
Lecture parallèle
Capacités : UI
GuiObject.ZIndex:number

Méthodes
TweenPosition
Déprécié

TweenSize
Déprécié

TweenSizeAndPosition
Déprécié

Événements
DragBegin
Déprécié

DragStopped
Déprécié

InputBegan
Capacités : UI
GuiObject.InputBegan(input:InputObject):RBXScriptSignal
Paramètres
Échantillons de code
Suivi du début de l'entrée sur un GuiObject
-- Pour utiliser l'événement InputBegan, vous devez spécifier le GuiObject
local gui = script.Parent
-- Une fonction d'exemple fournissant plusieurs cas d'utilisation pour différents types d'entrée utilisateur
local function inputBegan(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
print("Une touche est enfoncée ! Touche :", input.KeyCode)
elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
print("Le bouton gauche de la souris a été enfoncé à", input.Position)
elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
print("Le bouton droit de la souris a été enfoncé à", input.Position)
elseif input.UserInputType == Enum.UserInputType.Touch then
print("Une entrée tactile a commencé à", input.Position)
elseif input.UserInputType == Enum.UserInputType.Gamepad1 then
print("Un bouton est enfoncé sur un gamepad ! Bouton :", input.KeyCode)
end
end
gui.InputBegan:Connect(inputBegan)

InputChanged
Capacités : UI
GuiObject.InputChanged(input:InputObject):RBXScriptSignal
Paramètres
Échantillons de code
Démo InputChanged GuiObject
local UserInputService = game:GetService("UserInputService")
local gui = script.Parent
local function printMovement(input)
print("Position:", input.Position)
print("Délai de mouvement:", input.Delta)
end
local function inputChanged(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
print("La souris a été déplacée !")
printMovement(input)
elseif input.UserInputType == Enum.UserInputType.MouseWheel then
print("La molette de la souris a été tournée !")
print("Mouvement de la molette:", input.Position.Z)
elseif input.UserInputType == Enum.UserInputType.Gamepad1 then
if input.KeyCode == Enum.KeyCode.Thumbstick1 then
print("Le stick analogique gauche a été déplacé !")
printMovement(input)
elseif input.KeyCode == Enum.KeyCode.Thumbstick2 then
print("Le stick analogique droit a été déplacé !")
printMovement(input)
elseif input.KeyCode == Enum.KeyCode.ButtonL2 then
print("La pression appliquée au déclencheur gauche a changé !")
print("Pression:", input.Position.Z)
elseif input.KeyCode == Enum.KeyCode.ButtonR2 then
print("La pression appliquée au déclencheur droit a changé !")
print("Pression:", input.Position.Z)
end
elseif input.UserInputType == Enum.UserInputType.Touch then
print("Le doigt de l'utilisateur se déplace sur l'écran !")
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("La rotation de l'appareil mobile de l'utilisateur a changé !")
print("Position", rotCFrame.p)
print("Rotation:", rot)
elseif input.UserInputType == Enum.UserInputType.Accelerometer then
print("L'accélération de l'appareil mobile de l'utilisateur a changé !")
printMovement(input)
end
end
gui.InputChanged:Connect(inputChanged)

InputEnded
Capacités : UI
GuiObject.InputEnded(input:InputObject):RBXScriptSignal
Paramètres
Échantillons de code
Suivi de la fin d'entrée sur un GuiObject
-- Pour utiliser l'événement InputChanged, vous devez spécifier un GuiObject
local gui = script.Parent
-- Une fonction exemple fournissant plusieurs cas d'utilisation pour divers types d'entrées utilisateur
local function inputEnded(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
print("Une touche a été relâchée ! Touche :", input.KeyCode)
elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
print("Le bouton gauche de la souris a été relâché à", input.Position)
elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
print("Le bouton droit de la souris a été relâché à", input.Position)
elseif input.UserInputType == Enum.UserInputType.Touch then
print("Une entrée sur écran tactile a été relâchée à", input.Position)
elseif input.UserInputType == Enum.UserInputType.Gamepad1 then
print("Un bouton a été relâché sur une manette ! Bouton :", input.KeyCode)
end
end
gui.InputEnded:Connect(inputEnded)

MouseEnter
Capacités : UI
GuiObject.MouseEnter(
Paramètres
Échantillons de code
Impression où une souris entre dans un GuiObject
local guiObject = script.Parent
guiObject.MouseEnter:Connect(function(x, y)
print("Le curseur de la souris de l'utilisateur est entré dans le GuiObject à la position", x, ",", y)
end)

MouseLeave
Capacités : UI
GuiObject.MouseLeave(
Paramètres

MouseMoved
Capacités : UI
GuiObject.MouseMoved(
Paramètres

MouseWheelBackward
Capacités : UI
GuiObject.MouseWheelBackward(
Paramètres

MouseWheelForward
Capacités : UI
GuiObject.MouseWheelForward(
Paramètres

SelectionGained
Capacités : UI
GuiObject.SelectionGained():RBXScriptSignal
Échantillons de code
Gestion de la sélection GUI acquise
local guiObject = script.Parent
local function selectionGained()
print("L'utilisateur a sélectionné ce bouton avec une manette.")
end
guiObject.SelectionGained:Connect(selectionGained)

SelectionLost
Capacités : UI
GuiObject.SelectionLost():RBXScriptSignal
Échantillons de code
Gestion de la sélection de l'interface utilisateur perdue
local guiObject = script.Parent
local function selectionLost()
print("L'utilisateur n'a plus cet élément sélectionné avec sa manette.")
end
guiObject.SelectionLost:Connect(selectionLost)

TouchLongPress
Capacités : UI
GuiObject.TouchLongPress(
touchPositions:{any}, state:Enum.UserInputState
Paramètres
touchPositions:{any}
Échantillons de code
Déplacer l'élément UI avec TouchLongPress
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
-- Commencer un glissement
dragging = true
basePosition = frame.Position
startTouchPosition = touchPositions[1]
-- Colorer le frame pour indiquer que le glissement est en cours
borderColor3 = frame.BorderColor3
backgroundColor3 = frame.BackgroundColor3
frame.BorderColor3 = Color3.new(1, 1, 1) -- Blanc
frame.BackgroundColor3 = Color3.new(0, 0, 1) -- Bleu
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
-- Stopper le glissement
dragging = false
frame.BorderColor3 = borderColor3
frame.BackgroundColor3 = backgroundColor3
end
end
frame.TouchLongPress:Connect(onTouchLongPress)

TouchPan
Capacités : UI
GuiObject.TouchPan(
touchPositions:{any}, totalTranslation:Vector2, velocity:Vector2, state:Enum.UserInputState
Paramètres
touchPositions:{any}
totalTranslation:Vector2
velocity:Vector2
Échantillons de code
Élément UI en Panning
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
Capacités : UI
GuiObject.TouchPinch(
touchPositions:{any}, scale:number, velocity:number, state:Enum.UserInputState
Paramètres
touchPositions:{any}
scale:number
velocity:number
Échantillons de code
Échelle de pincement/tirage
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 -- Remarquez la multiplication ici
elseif state == Enum.UserInputState.End and dragging then
dragging = false
outerFrame.BackgroundTransparency = 0.75
end
end
outerFrame.TouchPinch:Connect(onTouchPinch)

TouchRotate
Capacités : UI
GuiObject.TouchRotate(
touchPositions:{any}, rotation:number, velocity:number, state:Enum.UserInputState
Paramètres
touchPositions:{any}
rotation:number
velocity:number
Échantillons de code
Rotation de Toucher
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
Capacités : UI
GuiObject.TouchSwipe(
swipeDirection:Enum.SwipeDirection, numberOfTouches:number
Paramètres
swipeDirection:Enum.SwipeDirection
numberOfTouches:number
Échantillons de code
Sélecteur de Couleur Rebondissant
local frame = script.Parent
frame.Active = true
-- À quelle distance le cadre doit-il rebondir lors d'un balayage réussi
local BOUNCE_DISTANCE = 50
-- État actuel du cadre
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)
-- Changer le BackgroundColor3 en fonction de la direction du balayage
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
-- Mettre à jour la couleur et faire rebondir le cadre un peu
updateColor()
frame.Position = basePosition + deltaPos
frame:TweenPosition(basePosition, Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 0.7, true)
end
frame.TouchSwipe:Connect(onTouchSwipe)
updateColor()

TouchTap
Capacités : UI
GuiObject.TouchTap(touchPositions:{any}):RBXScriptSignal
Paramètres
touchPositions:{any}
Échantillons de code
Activer/Désactiver la transparence
local frame = script.Parent
frame.Active = true
local function onTouchTap()
-- Activer/Désactiver la transparence de fond
if frame.BackgroundTransparency > 0 then
frame.BackgroundTransparency = 0
else
frame.BackgroundTransparency = 0.75
end
end
frame.TouchTap:Connect(onTouchTap)

©2026 Société Roblox. Roblox, le logo Roblox et Powering Imagination font partie de nos marques déposées aux États-Unis et dans d'autres pays.