기타/로블록스 & Lua
로블록스 사용자 키 입력 감지하기
푸쿠이
2021. 12. 29. 09:34
------------------------------------------------------------
-- 키보드 G를 누를 때 효과 테스트.
------------------------------------------------------------
local UserInput = game:GetService('UserInputService')
UserInput.InputBegan:Connect(function(input, gameProcessed)
if not gameProcessed then
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.G then
-- G키 눌렀음!!
end
end
end
end)
-- 로컬 스크립트에서는 플레이어 구할 때. (그냥 기록용. 키 입력과는 상관 없음.)
local LocalPlayer = game:GetService("Players").LocalPlayer
개발하면서 유용한 것 같다.
어떠한 기능을 만들고 어떻게 테스트하나 고민했는데, G 누를 때 기능 실행! 해놓으면 테스트하기 편하다.