Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

This KeyDown Script is not working....This Used to work for me in the past. What is wrong with it?

Asked by 6 years ago
Players = game.Players.LocalPlayer
mouse = Players:GetMouse()

mouse.KeyDown:connect(function(key)
 if key == "h" then
  print ("h")
 end
end)?

I haven't used roblox studio in a while. But I do remember this being able to work.

0
idk there is a question mark at the end so I guess remove it? CrazyTwinkle -1 — 6y
0
and make sure you are using a local script? CrazyTwinkle -1 — 6y
0
the question is a mistake here on the website it is not like that on studio OnlineSaiyan 28 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

I think your problem is the "h", as from what I know keybites were specific numbers that you used, not letters.

But might I recommend UserInputService? KeyDown is outdated, and this is the best way to do it. Put this in a LocalScript:

local player = game.Players.LocalPlayer

local userInputService = game:GetService("UserInputService")

userInputService.InputBegan:connect(function(userInput)
    if userInput.UserInputType == Enum.UserInputType.Keyboard then
        if userInput.KeyCode == Enum.KeyCode.H then --Make sure the Enum.KeyCode is before the character.
            print'h down'
        end
    end
end)

userInputService.InputEnded:connect(function(userInput)
    if userInput.UserInputType == Enum.UserInputType.Keyboard then
        if userInput.KeyCode == Enum.KeyCode.H then
            print'h up'
        end
    end
end)
Ad

Answer this question