The InputObject passed by GuiObject.InputBegan will not properly update its state or position if the InputType is “MouseButton1”
Expected Behavior
If you get an inputObject from GuiObject.InputBegan by holding down your mouse, the position and state of that inputObject should change as you move the mouse while the button is held down
Actual Behavior
The inputState of the inputObject remains “Began” as long as the mouse is held down, and the position does not change from the initial button down position.
Demonstration
I ran into this bug during a dev stream. Here’s a helpful video demonstration that clearly shows the actual behavior, the expected behavior and then the code at the end:
Code:
volumeFrame.bar.InputBegan:connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
local startPointX = volumeFrame.bar.AbsolutePosition.X
local endPointX = volumeFrame.bar.AbsolutePosition.X + volumeFrame.bar.AbsoluteSize.X
print("INPUT START", input.UserInputState, input.Position)
while input.UserInputState ~= Enum.UserInputState.Cancel and input.UserInputState ~= Enum.UserInputState.End do
print("INPUT TICK", input.UserInputState, input.Position)
local inputPointX = input.Position.X - startPointX
volumeFrame.bar.slider.Position = UDim2.new(math.clamp(inputPointX / (endPointX - startPointX), 0, 1), 0, 0.5, 0)
runService.Heartbeat:wait()
end
print("INPUT ENDED", input.UserInputState)
end
end)
The exact same code works perfectly well with a “Touch” inputObject, but not with a “MouseButton1” input object.
The MouseButton1 input object will continue to read the position of the initial button down, and will not update as the mouse is moved.