로블록스 게임제작

로컬 스크립트 - 이용자 버튼 입력 이벤트 감지

Dean83 2024. 2. 13. 11:38

클릭이벤트 혹은 특정 키 이벤트 입력 감지를 할 수 있다. 

캐릭터가 이동중인지 멈췄는지도 알 수 있다. 

 

1. 마우스 클릭 이벤트 감지

local mouse = player:GetMouse()
local function button1Up()
	
	....
    
    mouse.Target -- 마우스 클릭한 대상
	
end

mouse.Button1Up:Connect(button1Up)

 

2. 키 클릭 이벤트 감지

  • 키 클릭 또한 GetMouse 를 통해 이루어 진다.
local mouse = player:GetMouse()
mouse.KeyDown:connect(function (key) 
	key = string.lower(key)
	....
end)