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

player:GetMouse() is getting deprecated?

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
 
mouse:connect(function(key)

if key == "Q" then

print("this is local")


end

end)

basically this simple script just does not work, i don't know what is wrong used to work before

4 comments

0

Is this a script or a local script?

0

Local script on starter pack

0

the script says taht itself XD

0

I saw lol

2 answers

✓ Accepted answer

You're almost right.

'KeyDown' is getting deprecated!

The new method is UserInputService.

Here is a good method on using it.

New Code:

game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.Q then
		print("Q was pressed")
	end
end)

2 comments

0

Thank you!

0

Welcome

The answer is no, :GetMouse() is no getting deprecated. But Mouse is outdated, there are others which have more features, like UserInputService and ContextActionService. https://developer.roblox.com/articles/Keyboard-Input-Methods

There are still ways to use :GetMouse() like Mouse.Target and Mouse.TargetSurface and many others which can be very useful, you can see all of them by going to the object browser and look for Mouse.

1 comment

0

Thank you!

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