How to detect when the player right click

MouseOfPlayer.Mouse2Up:Connect(Function(mevioleatumadre)
       zoom = true
end)

It basically detects when the player right-clicks and what I want is for it to detect when he stops pressing it. If you think I should use another command, say so, you probably know more than me.

1 Like

You can use the InputObject given as the first parameter of the UserInputService.InputEnded event:

local UserInputService = game:GetService("UserInputService")

UserInputService.InputEnded:Connect(function(input, gameProcessedEvent)
    -- Checking if event is already processed by an Gui or the ContextActionService
    if (gameProcessedEvent) then
        return
    end

    if (input.UserInputType == Enum.UserInputType.MouseButton2) then
        -- Code that needs to be run if right mouse button is released
    end
end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.