Hi i am trying to bind a function when the player’s Right Mouse button is held and let go.
Is there any Enum.Keycode for this? Because i can’t bind Player:GetMouse().
Anyways this is the script:
ContextActionService:BindAction("ZoomIn", function(p3, InputState, p5)
if InputState == Enum.UserInputState.Begin then
Zoom("In") -- function zoom in
end
end, true, Enum.KeyCode.?) -- what keycode for right mouse button down???
If you would like to do it that way, please consider using Mouse. So there are 2 methods that might be helpful; Button2Up, Button2Down (For right click.)
You have to set up a boolean outside the event, and keep tracking if the player is still holding the right click.
Hi, i’ve already tried this but my game needs to have mobile support since a major part of my game plays on mobile. Is there really no possible way to detect if the player is holding Enum.UserInputType.MouseButton2?
You can still use ContextActionService to detect if the right mouse button is held down! This can be done with the InputState parameter. You would just have to also check for when the inputstate has ended like so:
ContextActionService:BindAction("ZoomIn", function(p3, InputState, p5)
if InputState == Enum.UserInputState.Begin then
Zoom("In") -- function zoom in
elseif InputState == Enum.UserInputState.End then
--<< Input has ended >>--
end
end, true, Enum.UserInputType.MouseButton2)
Both methods work but it just depends on what you prefer! Hope this helps!