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

.Keydown not activating?

Asked by 8 years ago

I feel really, really, really, REALLY... Stupid for asking this question, I forgot how to use .Keydown, have not used it in a while.. Here's what I have.

game.Players.LocalPlayer.KeyDown:connect(function(mouse)
    if mouse == "o" then
        if script.Parent.Command.Visible == true then
            script.Parent.Command.Visible = false
        end
    else
        script.Parent.Command.Visible = false
    end
end)
0
Just long time I feel stupid * sigh * ReturnValue 50 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

You need to declare the mouse:

local mouse = game.Players.LocalPlayer:GetMouse() -- !!!!!

mouse.KeyDown:connect(function(key)
    key = key:lower() -- make sure you make it lowercase for the 'if' to work!
    if key == "o" then
        -- code
    end
end)
Ad

Answer this question