IsMouseButtonPressed

Constructor:

IsMouseButtonPressed(mouseButton)

Description

Returns whether the given mouse button is being pressed or not.

Parameters

Variable name Type Default Description
mousButton string Input mouse button type

Return Value

Variable name Type Default Description
bool It is pressed or not

Examples

Keep monitoring whether the mouse button is pressed or not. Print True if the button is found to be pressed, otherwise print False

coroutine.start(function()
    while true do
        coroutine.wait(0.1)
        if UserInputService.IsMouseButtonPressed(UserInputType.MouseButton1) then
            print(tostring(UserInputService.IsMouseButtonPressed(UserInputType.MouseButton1)))
        end
    end
end)