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

KeyDown LocalScript not executing correctly?

Asked by 9 years ago
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(key)
    if key == "e" then
        print("e pressed")
    end
end)

This LocalScript is cloned and put into PlayerGui when a new player joins, and I've ensured that I'm cloning it correctly and everything and it just seems to refuse to do what I want it to, or seemingly run at all.

Is there some other event I should be using for key presses? I've been stuck trying to get this LocalScript to work for a large part of the day.

2 answers

Log in to vote
1
Answered by 9 years ago

Use UserInputService, KeyDown is practically deprecated now.

Link on how to use it: http://www.roblox.com/UserInputService-Example-item?id=247466751

Wiki:http://wiki.roblox.com/index.php?title=Gamepad_input#UserInputService_events

0
KeyDown actually *is* deprecated now, just so you know. adark 5487 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Well, KeyDown is depreciated but you can still do this:

http://prntscr.com/7ghv8k

Answer this question