Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

UserInputService doesn't detect mouse movement?

This has been an issue for me for quite some time now. Initially, I was unsure if this was ROBLOX's fault or my fault. But after waiting this long I'm just not sure anymore...

Here's a seemingly viable example of checking for mouse movement with UserInputService. I'm not sure if I'm missing something here, or if this has just been a thing with ROBLOX forever:

local inputService = game:GetService("UserInputService")

inputService.InputBegan:connect(function(input)
	print(input) -- Not even the MouseMovement input type shows.
end)

Nothing prints when the mouse is moved. I feel like I'm probably just missing something, but at the same time I see nothing wrong with this, for there's a UserInputType called MouseMovement. So, if anyone has any insight on this I'd appreciate it.


Edit:

It also doesn't detect any of the following UserInputTypes (including MouseMovement):

  • MouseWheel

  • TextInput

2 answers

✓ Accepted answer

The users mouse is a constant event so it will not end / have an end state.

You are able to use the 'InputChanged' event to find when the mouse is moved:-

local inputService = game:GetService("UserInputService")
local mouse = game.Players.LocalPlayer:GetMouse()

inputService.InputChanged:connect(function(input)
   print('inServ', input.UserInputType, input.Position,'mouse' ,mouse.X, mouse.Y)
end)

Hope this helps

I found that both MouseMovementand MouseWheel can be detected using InputChanged rather than InputBegan. I'm not sure about TextInput however.

1 comment

0

Thanks.

This discussion is preserved as it was. New answers, comments, and votes are closed.