PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

UserInputService

UserInputService

Sep 30 2018, 9:10 AM PST

The following example demonstrates one of many usage examples of handling a UserInputService event.

-- We must get the UserInputService before we can use it
local UserInputService = game:GetService("UserInputService")

-- A sample function providing one usage of InputBegan
local function onInputBegan(input, gameProcessed)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		print("The left mouse button has been pressed!")
	end
end

UserInputService.InputBegan:Connect(onInputBegan)