How do I prevent this?

I’m currently InputBegan to track mouse movements however it seems to act unexpectedtly when window is unfocused, any workarounds?

UserInputService.InputBegan:Connect(function(_input)
	if _input.Position then
		_startPosition = _input.Position
		print("started")
	end
end)

UserInputService.InputEnded:Connect(function(_input)
	if _input.Position then
		_endPosition = _input.Position
		
		DrawLine(Vector2.new(_startPosition.X, _startPosition.Y), Vector2.new(_endPosition.X, _endPosition.Y))
	
		print("ended")
	end
	
	print((_startPosition - _endPosition).Magnitude)
end)

image

You can’t. When the window isn’t focused, Roblox does not receive input events.

Edit: They’re right

Ignore the input if the window is unfocused

3 Likes