Informacje o wersji
Edukacja
Klasa silnika
GuiObject
Brak możliwości tworzenia
Brak możliwości przeglądania

*Ta zawartość została przetłumaczona przy użyciu narzędzi AI (w wersji beta) i może zawierać błędy. Aby wyświetlić tę stronę w języku angielskim, kliknij tutaj.


Podsumowanie
Metody
TweenPosition(endPosition: UDim2,easingDirection: Enum.EasingDirection,easingStyle: Enum.EasingStyle,time: number,override: boolean,callback: function):boolean
Przestarzałe
TweenSize(endSize: UDim2,easingDirection: Enum.EasingDirection,easingStyle: Enum.EasingStyle,time: number,override: boolean,callback: function):boolean
Przestarzałe
TweenSizeAndPosition(endSize: UDim2,endPosition: UDim2,easingDirection: Enum.EasingDirection,easingStyle: Enum.EasingStyle,time: number,override: boolean,callback: function):boolean
Przestarzałe
Członkowie odziedziczeni
Odziedziczone przez:

Materiały referencyjne dotyczące interfejsów API
Właściwości
Active
Odczyt równoległy
Możliwości: UI
GuiObject.Active:boolean
Przykłady kodu
Przycisk Tekstowy Aktywny Debounce
-- Umieść ten LocalScript w obrębie TextButton (lub ImageButton)
local textButton = script.Parent
textButton.Text = "Kliknij mnie"
textButton.Active = true
local function onActivated()
-- Działa jak debounce
textButton.Active = false
-- Licz w dół z 5
for i = 5, 1, -1 do
textButton.Text = "Czas: " .. i
task.wait(1)
end
textButton.Text = "Kliknij mnie"
textButton.Active = true
end
textButton.Activated:Connect(onActivated)

AnchorPoint
Odczyt równoległy
Możliwości: UI
GuiObject.AnchorPoint:Vector2
Przykłady kodu
Demonstracja AnchorPoint
local guiObject = script.Parent
while true do
-- Lewy górny róg
guiObject.AnchorPoint = Vector2.new(0, 0)
guiObject.Position = UDim2.new(0, 0, 0, 0)
task.wait(1)
-- Góra
guiObject.AnchorPoint = Vector2.new(0.5, 0)
guiObject.Position = UDim2.new(0.5, 0, 0, 0)
task.wait(1)
-- Prawy górny róg
guiObject.AnchorPoint = Vector2.new(1, 0)
guiObject.Position = UDim2.new(1, 0, 0, 0)
task.wait(1)
-- Lewy
guiObject.AnchorPoint = Vector2.new(0, 0.5)
guiObject.Position = UDim2.new(0, 0, 0.5, 0)
task.wait(1)
-- Idealne centrum
guiObject.AnchorPoint = Vector2.new(0.5, 0.5)
guiObject.Position = UDim2.new(0.5, 0, 0.5, 0)
task.wait(1)
-- Prawy
guiObject.AnchorPoint = Vector2.new(1, 0.5)
guiObject.Position = UDim2.new(1, 0, 0.5, 0)
task.wait(1)
-- Lewy dolny róg
guiObject.AnchorPoint = Vector2.new(0, 1)
guiObject.Position = UDim2.new(0, 0, 1, 0)
task.wait(1)
-- Dół
guiObject.AnchorPoint = Vector2.new(0.5, 1)
guiObject.Position = UDim2.new(0.5, 0, 1, 0)
task.wait(1)
-- Prawy dolny róg
guiObject.AnchorPoint = Vector2.new(1, 1)
guiObject.Position = UDim2.new(1, 0, 1, 0)
task.wait(1)
end

AutomaticSize
Odczyt równoległy
Możliwości: UI
GuiObject.AutomaticSize:Enum.AutomaticSize
Przykłady kodu
LocalScript w ScreenGui
-- Tablica etykiet tekstowych/czcionek/rozmiarów do wypisania
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 },
}
-- Utwórz automatycznie dostosowującą się ramkę rodzica
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
-- Dodaj układ listy
local listLayout = Instance.new("UIListLayout")
listLayout.Padding = UDim.new(0, 5)
listLayout.Parent = parentFrame
-- Ustaw zaokrąglone rogi i odstępy dla estetyki wizualnej
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
-- Utwórz automatycznie dostosowującą się etykietę tekstową z tablicy
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
-- Estetyka wizualna
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
Przestarzałe

BackgroundColor3
Odczyt równoległy
Możliwości: UI
GuiObject.BackgroundColor3:Color3
Przykłady kodu
Tęczowa Ramka
-- Umieść ten kod w LocalScript w Ramce
local frame = script.Parent
while true do
for hue = 0, 255, 4 do
-- HSV = odcień, nasycenie, wartość
-- Jeśli będziemy powtarzać pętlę od 0 do 1, otrzymamy tęczę!
frame.BorderColor3 = Color3.fromHSV(hue / 256, 1, 1)
frame.BackgroundColor3 = Color3.fromHSV(hue / 256, 0.5, 0.8)
task.wait()
end
end

BackgroundTransparency
Odczyt równoległy
Możliwości: UI
GuiObject.BackgroundTransparency:number

BorderColor
Przestarzałe

BorderColor3
Odczyt równoległy
Możliwości: UI
GuiObject.BorderColor3:Color3
Przykłady kodu
Podświetlenie Przycisku
-- Umieść mnie w jakimś GuiObject, najlepiej w ImageButton/TextButton
local button = script.Parent
local function onEnter()
button.BorderSizePixel = 2
button.BorderColor3 = Color3.new(1, 1, 0) -- Żółty
end
local function onLeave()
button.BorderSizePixel = 1
button.BorderColor3 = Color3.new(0, 0, 0) -- Czarny
end
-- Połącz zdarzenia
button.MouseEnter:Connect(onEnter)
button.MouseLeave:Connect(onLeave)
-- Nasz domyślny stan to "nie najechane"
onLeave()

BorderMode
Odczyt równoległy
Możliwości: UI
GuiObject.BorderMode:Enum.BorderMode

BorderSizePixel
Odczyt równoległy
Możliwości: UI
GuiObject.BorderSizePixel:number
Przykłady kodu
Podświetlenie Przycisku
-- Umieść mnie w jakimś GuiObject, najlepiej w ImageButton/TextButton
local button = script.Parent
local function onEnter()
button.BorderSizePixel = 2
button.BorderColor3 = Color3.new(1, 1, 0) -- Żółty
end
local function onLeave()
button.BorderSizePixel = 1
button.BorderColor3 = Color3.new(0, 0, 0) -- Czarny
end
-- Połącz zdarzenia
button.MouseEnter:Connect(onEnter)
button.MouseLeave:Connect(onLeave)
-- Nasz domyślny stan to "nie najechane"
onLeave()

ClipsDescendants
Odczyt równoległy
Możliwości: UI
GuiObject.ClipsDescendants:boolean

Draggable
Przestarzałe

GuiState
Tylko do odczytu
Bez replikacji
Odczyt równoległy
Możliwości: UI
GuiObject.GuiState:Enum.GuiState

InputSink
Odczyt równoległy
Możliwości: UI
GuiObject.InputSink:Enum.InputSink

Interactable
Odczyt równoległy
Możliwości: UI
GuiObject.Interactable:boolean

LayoutOrder
Odczyt równoległy
Możliwości: UI
GuiObject.LayoutOrder:number

NextSelectionDown
Odczyt równoległy
Możliwości: UI
GuiObject.NextSelectionDown:GuiObject
Przykłady kodu
Tworzenie siatki wyboru kontrolera
-- Ustaw siatkę wyboru kontrolera za pomocą poniższego kodu
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
-- Lewa krawędź
gui.NextSelectionLeft = container:FindFirstChild(pos - 1)
-- Prawa krawędź
gui.NextSelectionRight = container:FindFirstChild(pos + 1)
-- Powyżej
gui.NextSelectionUp = container:FindFirstChild(pos - rowSize)
-- Poniżej
gui.NextSelectionDown = container:FindFirstChild(pos + rowSize)
end
end
-- Testuj siatkę wyboru kontrolera za pomocą poniższego kodu
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
Odczyt równoległy
Możliwości: UI
GuiObject.NextSelectionLeft:GuiObject
Przykłady kodu
Tworzenie siatki wyboru kontrolera
-- Ustaw siatkę wyboru kontrolera za pomocą poniższego kodu
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
-- Lewa krawędź
gui.NextSelectionLeft = container:FindFirstChild(pos - 1)
-- Prawa krawędź
gui.NextSelectionRight = container:FindFirstChild(pos + 1)
-- Powyżej
gui.NextSelectionUp = container:FindFirstChild(pos - rowSize)
-- Poniżej
gui.NextSelectionDown = container:FindFirstChild(pos + rowSize)
end
end
-- Testuj siatkę wyboru kontrolera za pomocą poniższego kodu
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
Odczyt równoległy
Możliwości: UI
GuiObject.NextSelectionRight:GuiObject
Przykłady kodu
Tworzenie siatki wyboru kontrolera
-- Ustaw siatkę wyboru kontrolera za pomocą poniższego kodu
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
-- Lewa krawędź
gui.NextSelectionLeft = container:FindFirstChild(pos - 1)
-- Prawa krawędź
gui.NextSelectionRight = container:FindFirstChild(pos + 1)
-- Powyżej
gui.NextSelectionUp = container:FindFirstChild(pos - rowSize)
-- Poniżej
gui.NextSelectionDown = container:FindFirstChild(pos + rowSize)
end
end
-- Testuj siatkę wyboru kontrolera za pomocą poniższego kodu
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
Odczyt równoległy
Możliwości: UI
GuiObject.NextSelectionUp:GuiObject
Przykłady kodu
Tworzenie siatki wyboru kontrolera
-- Ustaw siatkę wyboru kontrolera za pomocą poniższego kodu
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
-- Lewa krawędź
gui.NextSelectionLeft = container:FindFirstChild(pos - 1)
-- Prawa krawędź
gui.NextSelectionRight = container:FindFirstChild(pos + 1)
-- Powyżej
gui.NextSelectionUp = container:FindFirstChild(pos - rowSize)
-- Poniżej
gui.NextSelectionDown = container:FindFirstChild(pos + rowSize)
end
end
-- Testuj siatkę wyboru kontrolera za pomocą poniższego kodu
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
Odczyt równoległy
Możliwości: UI
GuiObject.Position:UDim2

Rotation
Odczyt równoległy
Możliwości: UI
GuiObject.Rotation:number

Selectable
Odczyt równoległy
Możliwości: UI
GuiObject.Selectable:boolean
Przykłady kodu
Ograniczanie wyboru 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
-- Zdarzenie FocusLost i FocusGained uruchomi się, ponieważ textBox
-- jest typu TextBox
textBox.Focused:Connect(gainFocus)
textBox.FocusLost:Connect(loseFocus)

SelectionImageObject
Odczyt równoległy
Możliwości: UI
GuiObject.SelectionImageObject:GuiObject

SelectionOrder
Odczyt równoległy
Możliwości: UI
GuiObject.SelectionOrder:number

Size
Odczyt równoległy
Możliwości: UI
GuiObject.Size:UDim2
Przykłady kodu
Pasek zdrowia
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- Wklej skrypt do LocalScript, który jest
-- rodzicem dla Frame w Frame
local frame = script.Parent
local container = frame.Parent
container.BackgroundColor3 = Color3.new(0, 0, 0) -- czarny
-- Ta funkcja jest wywoływana, gdy zdrowie humanoida się zmienia
local function onHealthChanged()
local human = player.Character.Humanoid
local percent = human.Health / human.MaxHealth
-- Zmień rozmiar wewnętrznego paska
frame.Size = UDim2.new(percent, 0, 1, 0)
-- Zmień kolor paska zdrowia
if percent < 0.1 then
frame.BackgroundColor3 = Color3.new(1, 0, 0) -- czarny
elseif percent < 0.4 then
frame.BackgroundColor3 = Color3.new(1, 1, 0) -- żółty
else
frame.BackgroundColor3 = Color3.new(0, 1, 0) -- zielony
end
end
-- Ta funkcja jest wywoływana, gdy gracz się pojawia
local function onCharacterAdded(character)
local human = character:WaitForChild("Humanoid")
-- Wzór: aktualizuj raz teraz, a następnie za każdym razem, gdy zdrowie się zmienia
human.HealthChanged:Connect(onHealthChanged)
onHealthChanged()
end
-- Połącz nasz nasłuchujący obiekt do pojawienia się; wywołaj go, jeśli już się pojawił
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then
onCharacterAdded(player.Character)
end

SizeConstraint
Odczyt równoległy
Możliwości: UI
GuiObject.SizeConstraint:Enum.SizeConstraint

Transparency
Przestarzałe

Visible
Odczyt równoległy
Możliwości: UI
GuiObject.Visible:boolean
Przykłady kodu
Okno interfejsu użytkownika
local gui = script.Parent
local window = gui:WaitForChild("Window")
local toggleButton = gui:WaitForChild("ToggleWindow")
local closeButton = window:WaitForChild("Close")
local function toggleWindowVisbility()
-- Zmień wartość boolean za pomocą słowa kluczowego `not`
window.Visible = not window.Visible
end
toggleButton.Activated:Connect(toggleWindowVisbility)
closeButton.Activated:Connect(toggleWindowVisbility)

ZIndex
Odczyt równoległy
Możliwości: UI
GuiObject.ZIndex:number

Metody
TweenPosition
Przestarzałe

TweenSize
Przestarzałe

TweenSizeAndPosition
Przestarzałe

Zdarzenia
DragBegin
Przestarzałe

DragStopped
Przestarzałe

InputBegan
Możliwości: UI
GuiObject.InputBegan(input:InputObject):RBXScriptSignal
Parametry
Przykłady kodu
Śledzenie początku wprowadzenia na GuiObject
-- Aby używać zdarzenia InputBegan, musisz określić GuiObject
local gui = script.Parent
-- Funkcja przykładowa zapewniająca wiele przypadków użycia dla różnych typów wprowadzania użytkownika
local function inputBegan(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
print("Naciśnięto klawisz! Klawisz:", input.KeyCode)
elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
print("Lewy przycisk myszy został naciśnięty w", input.Position)
elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
print("Prawy przycisk myszy został naciśnięty w", input.Position)
elseif input.UserInputType == Enum.UserInputType.Touch then
print("Rozpoczęto wejście dotykowe w", input.Position)
elseif input.UserInputType == Enum.UserInputType.Gamepad1 then
print("Przycisk jest naciskany na gamepadzie! Przycisk:", input.KeyCode)
end
end
gui.InputBegan:Connect(inputBegan)

InputChanged
Możliwości: UI
GuiObject.InputChanged(input:InputObject):RBXScriptSignal
Parametry
Przykłady kodu
Demo zmiany wejścia obiektu GUI
local UserInputService = game:GetService("UserInputService")
local gui = script.Parent
local function printMovement(input)
print("Pozycja:", input.Position)
print("Delta ruchu:", input.Delta)
end
local function inputChanged(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
print("Mysz została przesunięta!")
printMovement(input)
elseif input.UserInputType == Enum.UserInputType.MouseWheel then
print("Kółko myszy zostało przesunięte!")
print("Ruch kółka:", input.Position.Z)
elseif input.UserInputType == Enum.UserInputType.Gamepad1 then
if input.KeyCode == Enum.KeyCode.Thumbstick1 then
print("Lewy analog został przesunięty!")
printMovement(input)
elseif input.KeyCode == Enum.KeyCode.Thumbstick2 then
print("Prawy analog został przesunięty!")
printMovement(input)
elseif input.KeyCode == Enum.KeyCode.ButtonL2 then
print("Ciśnienie na lewy spust się zmieniło!")
print("Ciśnienie:", input.Position.Z)
elseif input.KeyCode == Enum.KeyCode.ButtonR2 then
print("Ciśnienie na prawy spust się zmieniło!")
print("Ciśnienie:", input.Position.Z)
end
elseif input.UserInputType == Enum.UserInputType.Touch then
print("Palec użytkownika porusza się po ekranie!")
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("Obrót urządzenia mobilnego użytkownika się zmienił!")
print("Pozycja", rotCFrame.p)
print("Obrót:", rot)
elseif input.UserInputType == Enum.UserInputType.Accelerometer then
print("Przyspieszenie urządzenia mobilnego użytkownika się zmieniło!")
printMovement(input)
end
end
gui.InputChanged:Connect(inputChanged)

InputEnded
Możliwości: UI
GuiObject.InputEnded(input:InputObject):RBXScriptSignal
Parametry
Przykłady kodu
Śledzenie końca wejścia w GuiObject
-- Aby użyć zdarzenia InputChanged, musisz określić GuiObject
local gui = script.Parent
-- Przykładowa funkcja dostarczająca wiele przypadków użycia dla różnych typów wejścia od użytkowników
local function inputEnded(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
print("Zwolniono klawisz! Klawisz:", input.KeyCode)
elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
print("Lewy przycisk myszy został zwolniony w", input.Position)
elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
print("Prawy przycisk myszy został zwolniony w", input.Position)
elseif input.UserInputType == Enum.UserInputType.Touch then
print("Wejście dotykowe zostało zwolnione w", input.Position)
elseif input.UserInputType == Enum.UserInputType.Gamepad1 then
print("Przycisk został zwolniony na gamepadzie! Przycisk:", input.KeyCode)
end
end
gui.InputEnded:Connect(inputEnded)

MouseEnter
Możliwości: UI
GuiObject.MouseEnter(
Parametry
Przykłady kodu
Wyświetlanie, gdy kursor myszy wchodzi do GuiObject
local guiObject = script.Parent
guiObject.MouseEnter:Connect(function(x, y)
print("Kursor myszy użytkownika wszedł do GuiObject na pozycji", x, ",", y)
end)

MouseLeave
Możliwości: UI
GuiObject.MouseLeave(
Parametry

MouseMoved
Możliwości: UI
GuiObject.MouseMoved(
Parametry

MouseWheelBackward
Możliwości: UI
GuiObject.MouseWheelBackward(
Parametry

MouseWheelForward
Możliwości: UI
GuiObject.MouseWheelForward(
Parametry

SelectionGained
Możliwości: UI
GuiObject.SelectionGained():RBXScriptSignal
Przykłady kodu
Obsługa wyboru GUI
local guiObject = script.Parent
local function selectionGained()
print("Użytkownik wybrał ten przycisk za pomocą kontrolera.")
end
guiObject.SelectionGained:Connect(selectionGained)

SelectionLost
Możliwości: UI
GuiObject.SelectionLost():RBXScriptSignal
Przykłady kodu
Obsługa utraty wyboru GUI
local guiObject = script.Parent
local function selectionLost()
print("Użytkownik nie ma już tego wybranego za pomocą gamepada.")
end
guiObject.SelectionLost:Connect(selectionLost)

TouchLongPress
Możliwości: UI
GuiObject.TouchLongPress(
touchPositions:{any}, state:Enum.UserInputState
Parametry
touchPositions:{any}
Przykłady kodu
Przesuń element UI za pomocą 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
-- Rozpocznij przeciąganie
dragging = true
basePosition = frame.Position
startTouchPosition = touchPositions[1]
-- Zmień kolor ramki, aby wskazać, że przeciąganie trwa
borderColor3 = frame.BorderColor3
backgroundColor3 = frame.BackgroundColor3
frame.BorderColor3 = Color3.new(1, 1, 1) -- Biały
frame.BackgroundColor3 = Color3.new(0, 0, 1) -- Niebieski
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
-- Zatrzymaj przeciąganie
dragging = false
frame.BorderColor3 = borderColor3
frame.BackgroundColor3 = backgroundColor3
end
end
frame.TouchLongPress:Connect(onTouchLongPress)

TouchPan
Możliwości: UI
GuiObject.TouchPan(
touchPositions:{any}, totalTranslation:Vector2, velocity:Vector2, state:Enum.UserInputState
Parametry
touchPositions:{any}
totalTranslation:Vector2
velocity:Vector2
Przykłady kodu
Element UI do przesuwania
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
Możliwości: UI
GuiObject.TouchPinch(
touchPositions:{any}, scale:number, velocity:number, state:Enum.UserInputState
Parametry
touchPositions:{any}
scale:number
velocity:number
Przykłady kodu
Skalowanie przy pomocy pinch/pull
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 -- Zauważ mnożenie tutaj
elseif state == Enum.UserInputState.End and dragging then
dragging = false
outerFrame.BackgroundTransparency = 0.75
end
end
outerFrame.TouchPinch:Connect(onTouchPinch)

TouchRotate
Możliwości: UI
GuiObject.TouchRotate(
touchPositions:{any}, rotation:number, velocity:number, state:Enum.UserInputState
Parametry
touchPositions:{any}
rotation:number
velocity:number
Przykłady kodu
Obracanie przy dotyku
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
Możliwości: UI
GuiObject.TouchSwipe(
swipeDirection:Enum.SwipeDirection, numberOfTouches:number
Parametry
swipeDirection:Enum.SwipeDirection
numberOfTouches:number
Przykłady kodu
Bouncing Color Picker
local frame = script.Parent
frame.Active = true
-- Jak daleko ramka powinna skakać przy udanym przesunięciu
local BOUNCE_DISTANCE = 50
-- Bieżący stan ramki
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)
-- Zmień BackgroundColor3 w zależności od kierunku przesunięcia
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
-- Zaktualizuj kolor i lekko skocz ramką
updateColor()
frame.Position = basePosition + deltaPos
frame:TweenPosition(basePosition, Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 0.7, true)
end
frame.TouchSwipe:Connect(onTouchSwipe)
updateColor()

TouchTap
Możliwości: UI
GuiObject.TouchTap(touchPositions:{any}):RBXScriptSignal
Parametry
touchPositions:{any}
Przykłady kodu
Przełącznik Przezroczystości
local frame = script.Parent
frame.Active = true
local function onTouchTap()
-- Przełącz przezroczystość tła
if frame.BackgroundTransparency > 0 then
frame.BackgroundTransparency = 0
else
frame.BackgroundTransparency = 0.75
end
end
frame.TouchTap:Connect(onTouchTap)

©2026 Roblox Corporation. Nazwa Roblox, logo Roblox oraz hasło „Powering Imagination” należą do naszych zarejestrowanych i niezarejestrowanych znaków towarowych na terenie Stanów Zjednoczonych oraz w innych krajach.