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

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

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.

4 comments

0

idk there is a question mark at the end so I guess remove it?

0

and make sure you are using a local script?

0

the question is a mistake here on the website it is not like that on studio

1 answer

✓ Accepted answer

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)

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