배우기
엔진 클래스
UserInputService
만들 수 없음
서비스
복제되지 않음

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.


요약
이벤트
InputBegan(input: InputObject,gameProcessedEvent: boolean):RBXScriptSignal
InputChanged(input: InputObject,gameProcessedEvent: boolean):RBXScriptSignal
InputEnded(input: InputObject,gameProcessedEvent: boolean):RBXScriptSignal
PointerAction(wheel: number,pan: Vector2,pinch: number,gameProcessedEvent: boolean):RBXScriptSignal
TouchDrag(dragDirection: Enum.SwipeDirection,numberOfTouches: number,gameProcessedEvent: boolean):RBXScriptSignal
TouchEnded(touch: InputObject,gameProcessedEvent: boolean):RBXScriptSignal
TouchLongPress(touchPositions: {any},state: Enum.UserInputState,gameProcessedEvent: boolean):RBXScriptSignal
TouchMoved(touch: InputObject,gameProcessedEvent: boolean):RBXScriptSignal
TouchPan(touchPositions: {any},totalTranslation: Vector2,velocity: Vector2,state: Enum.UserInputState,gameProcessedEvent: boolean):RBXScriptSignal
TouchPinch(touchPositions: {any},scale: number,velocity: number,state: Enum.UserInputState,gameProcessedEvent: boolean):RBXScriptSignal
TouchRotate(touchPositions: {any},rotation: number,velocity: number,state: Enum.UserInputState,gameProcessedEvent: boolean):RBXScriptSignal
TouchStarted(touch: InputObject,gameProcessedEvent: boolean):RBXScriptSignal
TouchSwipe(swipeDirection: Enum.SwipeDirection,numberOfTouches: number,gameProcessedEvent: boolean):RBXScriptSignal
TouchTap(touchPositions: {any},gameProcessedEvent: boolean):RBXScriptSignal
UserCFrameChanged(type: Enum.UserCFrame,value: CFrame):RBXScriptSignal
사용되지 않음
상속된 멤버

API 참조
속성
AccelerometerEnabled
읽기 전용
복제되지 않음
병렬 읽기
기능: Input
UserInputService.AccelerometerEnabled:boolean
코드 샘플
가속도계를 사용하여 공 이동하기
local Workspace = game:GetService("Workspace")
local UserInputService = game:GetService("UserInputService")
local ball = script.Parent:WaitForChild("Ball")
local mass = ball:GetMass()
local gravityForce = ball:WaitForChild("GravityForce")
local function moveBall(gravity)
gravityForce.Force = gravity.Position * Workspace.Gravity * mass
end
if UserInputService.AccelerometerEnabled then
UserInputService.DeviceGravityChanged:Connect(moveBall)
end

GamepadEnabled
읽기 전용
복제되지 않음
병렬 읽기
기능: Input
UserInputService.GamepadEnabled:boolean

GyroscopeEnabled
읽기 전용
복제되지 않음
병렬 읽기
기능: Input
UserInputService.GyroscopeEnabled:boolean

KeyboardEnabled
읽기 전용
복제되지 않음
병렬 읽기
기능: Input
UserInputService.KeyboardEnabled:boolean

ModalEnabled
사용되지 않음

MouseBehavior
병렬 읽기
기능: Input
UserInputService.MouseBehavior:Enum.MouseBehavior

MouseDeltaSensitivity
복제되지 않음
병렬 읽기
기능: Input
UserInputService.MouseDeltaSensitivity:number

MouseEnabled
읽기 전용
복제되지 않음
병렬 읽기
기능: Input
UserInputService.MouseEnabled:boolean

MouseIcon
병렬 읽기
기능: Input
UserInputService.MouseIcon:ContentId
코드 샘플
커스텀 마우스 아이콘
local UserInputService = game:GetService("UserInputService")
-- 커서를 이전 설정으로 복원하기 위해서는 변수를 통해 저장해야 합니다.
local savedCursor = nil
local function setTemporaryCursor(cursor: string)
-- 현재 저장되지 않은 경우에만 저장된 커서를 업데이트합니다.
if not savedCursor then
savedCursor = UserInputService.MouseIcon
end
UserInputService.MouseIcon = cursor
end
local function clearTemporaryCursor()
-- 저장된 커서가 있을 경우에만 마우스 커서를 복원합니다.
if savedCursor then
UserInputService.MouseIcon = savedCursor
-- 같은 커서를 두 번 복원하지 않습니다 (다른 스크립트를 덮어쓸 수 있습니다).
savedCursor = nil
end
end
setTemporaryCursor("http://www.roblox.com/asset?id=163023520")
print(UserInputService.MouseIcon)
clearTemporaryCursor()

MouseIconContent
병렬 읽기
기능: Input
UserInputService.MouseIconContent:Content
코드 샘플
커스텀 마우스 아이콘
local UserInputService = game:GetService("UserInputService")
-- 커서를 이전 설정으로 복원하기 위해서는 변수를 통해 저장해야 합니다.
local savedCursor = nil
local function setTemporaryCursor(cursor: string)
-- 현재 저장되지 않은 경우에만 저장된 커서를 업데이트합니다.
if not savedCursor then
savedCursor = UserInputService.MouseIcon
end
UserInputService.MouseIcon = cursor
end
local function clearTemporaryCursor()
-- 저장된 커서가 있을 경우에만 마우스 커서를 복원합니다.
if savedCursor then
UserInputService.MouseIcon = savedCursor
-- 같은 커서를 두 번 복원하지 않습니다 (다른 스크립트를 덮어쓸 수 있습니다).
savedCursor = nil
end
end
setTemporaryCursor("http://www.roblox.com/asset?id=163023520")
print(UserInputService.MouseIcon)
clearTemporaryCursor()

MouseIconEnabled
병렬 읽기
기능: Input
UserInputService.MouseIconEnabled:boolean

OnScreenKeyboardPosition
읽기 전용
복제되지 않음
병렬 읽기
기능: Input
UserInputService.OnScreenKeyboardPosition:Vector2

OnScreenKeyboardSize
읽기 전용
복제되지 않음
병렬 읽기
기능: Input
UserInputService.OnScreenKeyboardSize:Vector2

OnScreenKeyboardVisible
읽기 전용
복제되지 않음
병렬 읽기
기능: Input
UserInputService.OnScreenKeyboardVisible:boolean

PreferredInput
읽기 전용
복제되지 않음
병렬 읽기
기능: Input
UserInputService.PreferredInput:Enum.PreferredInput
코드 샘플
선호 입력 감지
local UserInputService = game:GetService("UserInputService")
local function preferredInputChanged()
local preferredInput = UserInputService.PreferredInput
if preferredInput == Enum.PreferredInput.Touch then
-- 플레이어는 다른 입력 유형이 사용 가능/연결되지 않은 터치 지원 장치에 있습니다.
print("Touch")
elseif preferredInput == Enum.PreferredInput.Gamepad then
-- 플레이어는 게임패드를 연결했거나 최근에 상호작용했습니다.
print("Gamepad")
elseif preferredInput == Enum.PreferredInput.KeyboardAndMouse then
-- 플레이어는 키보드 또는 마우스를 연결했거나 최근에 상호작용했습니다.
print("KeyboardAndMouse")
end
end
preferredInputChanged()
UserInputService:GetPropertyChangedSignal("PreferredInput"):Connect(function()
preferredInputChanged()
end)

TouchEnabled
읽기 전용
복제되지 않음
병렬 읽기
기능: Input
UserInputService.TouchEnabled:boolean

TouchScreenEnabled
읽기 전용
복제되지 않음
Roblox 스크립트 보안
병렬 읽기
기능: Input
UserInputService.TouchScreenEnabled:boolean

UserHeadCFrame
사용되지 않음

VREnabled
사용되지 않음

메서드
CreateVirtualInput
기능: Input
UserInputService:CreateVirtualInput():Object
반환

GamepadSupports
기능: Input
UserInputService:GamepadSupports(
gamepadNum:Enum.UserInputType, gamepadKeyCode:Enum.KeyCode
매개 변수
gamepadKeyCode:Enum.KeyCode
반환

GetConnectedGamepads
기능: Input
UserInputService:GetConnectedGamepads():{any}
반환

GetDeviceAcceleration
기능: Input
UserInputService:GetDeviceAcceleration():InputObject
코드 샘플
출력 장치 가속화
local UserInputService = game:GetService("UserInputService")
if UserInputService.AccelerometerEnabled then
local acceleration = UserInputService:GetDeviceAcceleration().Position
print(acceleration)
else
warn("장치에 활성화된 가속도가 없기 때문에 장치 가속도를 가져올 수 없습니다!")
end

GetDeviceGravity
기능: Input
UserInputService:GetDeviceGravity():InputObject
코드 샘플
자이로스코프를 이용한 물체 이동
local UserInputService = game:GetService("UserInputService")
local bubble = script.Parent:WaitForChild("Bubble")
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new(0, 20, 0) * CFrame.Angles(-math.pi / 2, 0, 0)
if UserInputService.GyroscopeEnabled then
-- 자이로스코프가 변화를 감지할 때 이벤트 바인딩
UserInputService.DeviceGravityChanged:Connect(function(accel)
-- 자이로스코프 데이터를 기반으로 세상에서 버블을 이동
bubble.Position = Vector3.new(-8 * accel.Position.X, 1.8, -8 * accel.Position.Z)
end)
end

GetDeviceRotation
기능: Input
UserInputService:GetDeviceRotation():Tuple
반환
코드 샘플
출력 장치 회전
local UserInputService = game:GetService("UserInputService")
if UserInputService.GyroscopeEnabled then
local _, cf = UserInputService:GetDeviceRotation()
print(cf)
else
warn("장치에 활성화된 자이로스코프가 없어서 장치 회전을 가져올 수 없습니다!")
end

GetFocusedTextBox
기능: Input
UserInputService:GetFocusedTextBox():TextBox
반환

GetGamepadConnected
기능: Input
UserInputService:GetGamepadConnected(gamepadNum:Enum.UserInputType):boolean
매개 변수
반환

GetGamepadState
기능: Input
UserInputService:GetGamepadState(gamepadNum:Enum.UserInputType):{InputObject}
매개 변수
반환

GetImageForKeyCode
기능: Input
UserInputService:GetImageForKeyCode(keyCode:Enum.KeyCode):ContentId
매개 변수
keyCode:Enum.KeyCode
반환
ContentId
코드 샘플
UserInputService - KeyCode에 대한 이미지 가져오기
local UserInputService = game:GetService("UserInputService")
local imageLabel = script.Parent
local key = Enum.KeyCode.ButtonA
local mappedIconImage = UserInputService:GetImageForKeyCode(key)
imageLabel.Image = mappedIconImage

GetKeysPressed
기능: Input
UserInputService:GetKeysPressed():{InputObject}
반환

GetLastInputType
기능: Input
UserInputService:GetLastInputType():Enum.UserInputType
코드 샘플
마지막 입력 유형 감지
local UserInputService = game:GetService("UserInputService")
if UserInputService:GetLastInputType() == Enum.UserInputType.Keyboard then
print("가장 최근 입력은 키보드입니다!")
end

GetMouseButtonsPressed
기능: Input
UserInputService:GetMouseButtonsPressed():{InputObject}
반환
코드 샘플
눌린 마우스 버튼 확인
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
-- 눌린 마우스 버튼의 배열을 반환합니다
local buttonsPressed = UserInputService:GetMouseButtonsPressed()
local m1, m2 = false, false
for _, button in buttonsPressed do
if button.UserInputType == Enum.UserInputType.MouseButton1 then
print("MouseButton1이 눌렸습니다!")
m1 = true
end
if button.UserInputType == Enum.UserInputType.MouseButton2 then
print("MouseButton2가 눌렸습니다!")
m2 = true
end
if m1 and m2 then
print("두 마우스 버튼이 모두 눌렸습니다!")
end
end
end)

GetMouseDelta
기능: Input
UserInputService:GetMouseDelta():Vector2
반환
코드 샘플
마우스 델타 가져오기
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
local function onRenderStep()
local delta = UserInputService:GetMouseDelta()
if delta ~= Vector2.new(0, 0) then
print("마우스가 이동했습니다", delta, "마지막 단계 이후")
end
end
RunService:BindToRenderStep("MeasureMouseMovement", Enum.RenderPriority.Input.Value, onRenderStep)

GetMouseLocation
기능: Input
UserInputService:GetMouseLocation():Vector2
반환

GetNavigationGamepads
기능: Input
UserInputService:GetNavigationGamepads():{any}
반환

GetStringForKeyCode
기능: Input
UserInputService:GetStringForKeyCode(
매개 변수
keyCode:Enum.KeyCode
기본값: "Default"
반환

GetSupportedGamepadKeyCodes
기능: Input
UserInputService:GetSupportedGamepadKeyCodes(gamepadNum:Enum.UserInputType):{any}
매개 변수
반환

GetUserCFrame
사용되지 않음

IsGamepadButtonDown
기능: Input
UserInputService:IsGamepadButtonDown(
gamepadNum:Enum.UserInputType, gamepadKeyCode:Enum.KeyCode
매개 변수
gamepadKeyCode:Enum.KeyCode
반환

IsKeyDown
기능: Input
UserInputService:IsKeyDown(keyCode:Enum.KeyCode):boolean
매개 변수
keyCode:Enum.KeyCode
반환

IsMouseButtonPressed
기능: Input
UserInputService:IsMouseButtonPressed(mouseButton:Enum.UserInputType):boolean
매개 변수
mouseButton:Enum.UserInputType
반환

IsNavigationGamepad
기능: Input
UserInputService:IsNavigationGamepad(gamepadEnum:Enum.UserInputType):boolean
매개 변수
gamepadEnum:Enum.UserInputType
반환

RecenterUserHeadCFrame
기능: Input
UserInputService:RecenterUserHeadCFrame():()
반환
()

SetNavigationGamepad
기능: Input
UserInputService:SetNavigationGamepad(
gamepadEnum:Enum.UserInputType, enabled:boolean
):()
매개 변수
gamepadEnum:Enum.UserInputType
enabled:boolean
반환
()

이벤트
DeviceAccelerationChanged
기능: Input
UserInputService.DeviceAccelerationChanged(acceleration:InputObject):RBXScriptSignal
매개 변수
acceleration:InputObject
코드 샘플
가속도계를 사용하여 플레이어 제어하기
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local SENSITIVITY = 0.2
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local ready = true
local function changeAcceleration(acceleration)
if ready then
ready = false
local accel = acceleration.Position
if accel.Y >= SENSITIVITY then
humanoid.Jump = true
end
if accel.Z <= -SENSITIVITY then
humanoid:Move(Vector3.new(-1, 0, 0))
end
if accel.Z >= SENSITIVITY then
humanoid:Move(Vector3.new(1, 0, 0))
end
if accel.X <= -SENSITIVITY then
humanoid:Move(Vector3.new(0, 0, 1))
end
if accel.X >= SENSITIVITY then
humanoid:Move(Vector3.new(0, 0, -1))
end
task.wait(1)
ready = true
end
end
if UserInputService.AccelerometerEnabled then
UserInputService.DeviceAccelerationChanged:Connect(changeAcceleration)
end

DeviceGravityChanged
기능: Input
UserInputService.DeviceGravityChanged(gravity:InputObject):RBXScriptSignal
매개 변수
gravity:InputObject
코드 샘플
가속도계를 사용하여 공 이동하기
local Workspace = game:GetService("Workspace")
local UserInputService = game:GetService("UserInputService")
local ball = script.Parent:WaitForChild("Ball")
local mass = ball:GetMass()
local gravityForce = ball:WaitForChild("GravityForce")
local function moveBall(gravity)
gravityForce.Force = gravity.Position * Workspace.Gravity * mass
end
if UserInputService.AccelerometerEnabled then
UserInputService.DeviceGravityChanged:Connect(moveBall)
end

DeviceRotationChanged
기능: Input
UserInputService.DeviceRotationChanged(
rotation:InputObject, cframe:CFrame
매개 변수
rotation:InputObject
cframe:CFrame

GamepadConnected
기능: Input
UserInputService.GamepadConnected(gamepadNum:Enum.UserInputType):RBXScriptSignal
매개 변수

GamepadDisconnected
기능: Input
UserInputService.GamepadDisconnected(gamepadNum:Enum.UserInputType):RBXScriptSignal
매개 변수

InputBegan
기능: Input
UserInputService.InputBegan(
input:InputObject, gameProcessedEvent:boolean
매개 변수
gameProcessedEvent:boolean

InputChanged
기능: Input
UserInputService.InputChanged(
input:InputObject, gameProcessedEvent:boolean
매개 변수
gameProcessedEvent:boolean

InputEnded
기능: Input
UserInputService.InputEnded(
input:InputObject, gameProcessedEvent:boolean
매개 변수
gameProcessedEvent:boolean

JumpRequest
기능: Input
UserInputService.JumpRequest():RBXScriptSignal
코드 샘플
기본 점프 비활성화
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
local processJumpRequest = false
local COOLDOWN_TIME = 0.5
local function jumpRequest()
if processJumpRequest == false then
processJumpRequest = true
-- 사용자 정의 점프 요청 처리
print("점프 요청됨!")
-- 쿨타임 후 디바운스 변수 리셋
task.wait(COOLDOWN_TIME)
processJumpRequest = false
end
end
UserInputService.JumpRequest:Connect(jumpRequest)

LastInputTypeChanged
기능: Input
UserInputService.LastInputTypeChanged(lastInputType:Enum.UserInputType):RBXScriptSignal
매개 변수
lastInputType:Enum.UserInputType

PointerAction
기능: Input
UserInputService.PointerAction(
wheel:number, pan:Vector2, pinch:number, gameProcessedEvent:boolean
매개 변수
wheel:number
pinch:number
gameProcessedEvent:boolean

TextBoxFocused
기능: Input
UserInputService.TextBoxFocused(textboxFocused:TextBox):RBXScriptSignal
매개 변수
textboxFocused:TextBox
코드 샘플
포커스된 텍스트 박스 수정
local UserInputService = game:GetService("UserInputService")
local function textBoxFocused(textBox)
textBox.BackgroundTransparency = 0
end
local function textBoxFocusReleased(textBox)
textBox.BackgroundTransparency = 0.5
end
UserInputService.TextBoxFocused:Connect(textBoxFocused)
UserInputService.TextBoxFocusReleased:Connect(textBoxFocusReleased)

TextBoxFocusReleased
기능: Input
UserInputService.TextBoxFocusReleased(textboxReleased:TextBox):RBXScriptSignal
매개 변수
textboxReleased:TextBox
코드 샘플
포커스된 텍스트 박스 수정
local UserInputService = game:GetService("UserInputService")
local function textBoxFocused(textBox)
textBox.BackgroundTransparency = 0
end
local function textBoxFocusReleased(textBox)
textBox.BackgroundTransparency = 0.5
end
UserInputService.TextBoxFocused:Connect(textBoxFocused)
UserInputService.TextBoxFocusReleased:Connect(textBoxFocusReleased)

TouchDrag
기능: Input
UserInputService.TouchDrag(
dragDirection:Enum.SwipeDirection, numberOfTouches:number, gameProcessedEvent:boolean
매개 변수
dragDirection:Enum.SwipeDirection
numberOfTouches:number
gameProcessedEvent:boolean

TouchEnded
기능: Input
UserInputService.TouchEnded(
touch:InputObject, gameProcessedEvent:boolean
매개 변수
gameProcessedEvent:boolean

TouchLongPress
기능: Input
UserInputService.TouchLongPress(
touchPositions:{any}, state:Enum.UserInputState, gameProcessedEvent:boolean
매개 변수
touchPositions:{any}
gameProcessedEvent:boolean

TouchMoved
기능: Input
UserInputService.TouchMoved(
touch:InputObject, gameProcessedEvent:boolean
매개 변수
gameProcessedEvent:boolean

TouchPan
기능: Input
UserInputService.TouchPan(
touchPositions:{any}, totalTranslation:Vector2, velocity:Vector2, state:Enum.UserInputState, gameProcessedEvent:boolean
매개 변수
touchPositions:{any}
totalTranslation:Vector2
velocity:Vector2
gameProcessedEvent:boolean

TouchPinch
기능: Input
UserInputService.TouchPinch(
touchPositions:{any}, scale:number, velocity:number, state:Enum.UserInputState, gameProcessedEvent:boolean
매개 변수
touchPositions:{any}
scale:number
velocity:number
gameProcessedEvent:boolean

TouchRotate
기능: Input
UserInputService.TouchRotate(
touchPositions:{any}, rotation:number, velocity:number, state:Enum.UserInputState, gameProcessedEvent:boolean
매개 변수
touchPositions:{any}
rotation:number
velocity:number
gameProcessedEvent:boolean

TouchStarted
기능: Input
UserInputService.TouchStarted(
touch:InputObject, gameProcessedEvent:boolean
매개 변수
gameProcessedEvent:boolean

TouchSwipe
기능: Input
UserInputService.TouchSwipe(
swipeDirection:Enum.SwipeDirection, numberOfTouches:number, gameProcessedEvent:boolean
매개 변수
swipeDirection:Enum.SwipeDirection
numberOfTouches:number
gameProcessedEvent:boolean

TouchTap
기능: Input
UserInputService.TouchTap(
touchPositions:{any}, gameProcessedEvent:boolean
매개 변수
touchPositions:{any}
gameProcessedEvent:boolean

TouchTapInWorld
기능: Input
UserInputService.TouchTapInWorld(
position:Vector2, processedByUI:boolean
매개 변수
position:Vector2
processedByUI:boolean

UserCFrameChanged
사용되지 않음

WindowFocused
기능: Input
UserInputService.WindowFocused():RBXScriptSignal

WindowFocusReleased
기능: Input
UserInputService.WindowFocusReleased():RBXScriptSignal
코드 샘플
창 포커스 이탈 스크립트 (LocalScript)
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local awayEvent = ReplicatedStorage:WaitForChild("AwayEvent")
local function focusGained()
awayEvent:FireServer(false)
end
local function focusReleased()
awayEvent:FireServer(true)
end
UserInputService.WindowFocused:Connect(focusGained)
UserInputService.WindowFocusReleased:Connect(focusReleased)
창 포커스 이탈 스크립트 (스크립트)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local awayEvent = Instance.new("RemoteEvent")
awayEvent.Name = "AwayEvent"
awayEvent.Parent = ReplicatedStorage
local function manageForceField(player, away)
if away then
local forceField = Instance.new("ForceField")
forceField.Parent = player.Character
else
local forceField = player.Character:FindFirstChildOfClass("ForceField")
if forceField then
forceField:Destroy()
end
end
end
awayEvent.OnServerEvent:Connect(manageForceField)

©2026 Roblox Corporation. Roblox 및 Roblox 로고, 'Powering Imagination'은 미국 및 기타 국가 내 당사의 등록 및 미등록 상표입니다.