InputObject unexpectedly changing UserInputState while holding an arrow key

This bug only appears to happen in studio.

While holding an arrow key, after approximately 0.5 seconds the InputObject’s UserInputState will rapidly change between End and Begin (in the same frame) many times per second until another arrow key is pressed or the original arrow key press is stopped.

Example place demonstrating this bug:

Hold down the up arrow and watch the output (while running the game in studio), the UserInputState will change from Begin to End many times per second.

Code used in example place
local ContextActionService = game:GetService"ContextActionService"
local RunService = game:GetService"RunService"
local RenderStepped = RunService.RenderStepped
local IsHolding = false
ContextActionService:BindActionAtPriority("Hold",function(_,State,Input)
	if State == Enum.UserInputState.Begin then
		if IsHolding then
			print"already holding"
			return Enum.ContextActionResult.Pass
		end
		IsHolding = true
		local ChangedSignal = Input:GetPropertyChangedSignal"UserInputState"
		local Con
		Con = ChangedSignal:Connect(function()
			print(os.clock(),"-",Input.UserInputState)
			if Input.UserInputState == Enum.UserInputState.End then
				local InnerCon
				InnerCon = ChangedSignal:Connect(function()
					InnerCon:Disconnect()
				end)
				RenderStepped:Wait()
				if Input.UserInputState == Enum.UserInputState.End and InnerCon.Connected then
					print"input finished"
					Con:Disconnect()
					IsHolding = false
				end
				if InnerCon.Connected then
					InnerCon:Disconnect()
				end
			end
		end)
		print(os.clock(),"-",Input.UserInputState)
	end
	return Enum.ContextActionResult.Pass
end,false,Enum.ContextActionPriority.High.Value+10,Enum.KeyCode.Up)

This is the output I got after holding the up arrow key for approximately 1 second.

473697.064993 - Enum.UserInputState.Begin
473697.5645211 - Enum.UserInputState.End
473697.565254 - Enum.UserInputState.Begin
473697.5975291 - Enum.UserInputState.End
473697.5982472 - Enum.UserInputState.Begin
473697.6318508 - Enum.UserInputState.End
473697.6325546 - Enum.UserInputState.Begin
473697.6653624 - Enum.UserInputState.End
473697.6661368 - Enum.UserInputState.Begin
473697.6977104 - Enum.UserInputState.End
473697.698467 - Enum.UserInputState.Begin
473697.7308369 - Enum.UserInputState.End
473697.7315519 - Enum.UserInputState.Begin
473697.7638633 - Enum.UserInputState.End
473697.7645812 - Enum.UserInputState.Begin
473697.7978693 - Enum.UserInputState.End
473697.7985599 - Enum.UserInputState.Begin
473697.830762 - Enum.UserInputState.End
473697.8314158 - Enum.UserInputState.Begin
473697.867414 - Enum.UserInputState.End
473697.8680499 - Enum.UserInputState.Begin
473697.8975887 - Enum.UserInputState.End
473697.8982908 - Enum.UserInputState.Begin
473697.9306515 - Enum.UserInputState.End
473697.9313467 - Enum.UserInputState.Begin
473697.9636505 - Enum.UserInputState.End
473697.9644495 - Enum.UserInputState.Begin
473697.9976086 - Enum.UserInputState.End
473697.9984759 - Enum.UserInputState.Begin
473698.0306616 - Enum.UserInputState.End
473698.0314698 - Enum.UserInputState.Begin
473698.0476703 - Enum.UserInputState.End
input finished

I’m not sure when this bug started, but I know its existed for at least the past month and a half (when I discovered it).

1 Like

Thank you for the report! And for the repro place, it is highly appreciated. Can you tell me what platform this occurs for you on? I just tried on macOS and it does not do the repeats.

2 Likes

Ah I just saw the bit about studio, does this happen in the game client as well? Or just studio?
I tried in studio on macOS and was not able to repro. I assume this is probably only occurring on Windows and will check it out.

2 Likes

I used studio (version 0.455.0.413788) on Windows.

This bug only happens in studio, and doesn’t happen on the game client. The game client functions as expected, UserInputState only gets set to end when the input finishes.

I have been able to repro on windows Studio. We will look into this, thanks again!

2 Likes