Mouse issues localscript

Hello, does anyone know what is wrong with my code? does not print when I press the A key.

local Players = game:GetService("Players")

local player = Players.LocalPlayer

local mouse = player:GetMouse()

if Enum.KeyCode == Enum.KeyCode.A then

print(mouse.Hit)

end

Yes there is a lot wrong here:

You are just saying

if Enum.KeyCode == Enum.KeyCode.A

what’s Enum.KeyCode?


I believe what you are trying to do is use UserInputService to detect when someone presses “A” for that you would use the InputBegan event

like so:

UserInputService.InputBegan:Connect(function(input)
     if input.KeyCode == Enum.KeyCode.A then
         print(mouse.Hit)
     end
end)
1 Like