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

I don't understand :IsKeyDown(keycode)?

Asked by 8 years ago

Hi guys, I checked the wiki and it didn't give me much detail.. I want a Gui to pop up when the M key is pressed.

This is what I tried but to me it didn't make sense.

game:GetService("UserInputService"):IsKeyDown(109):connect(function()
    game.Players.LocalPlayer.PlayerGui.MenuGui.Frame.Visible = true
end)

Could someone please tell me 1) If that code would work 2) How to use :IsKeyDown() properly please?

Many Thanks, Fahmi

0
You could answer point 1 by trying it yourself? Uroxus 350 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago

IsKeyDown is only for checking the current state of the keyboard. It isn't an event, it's a method.

You should read the wiki article on UserInputService before you start trying things randomly. If you're confused on how to do things, you could try reading this blog post which covers being able to use your resources in order to help you make games more effectively.

You want to use the InputBegan event of UserInputService.


game:GetService("UserInputService").InputBegan:connect(function(input) if input.KeyCode == Enum.KeyCode.M then gui.Visible = not gui.Visible end end)
Ad

Answer this question