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

Activate a GUI by pressing a key? [closed]

Asked by 8 years ago

I need to know how to activate the menu in my game with the m key. Please help.

Locked by User#19524

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
1
Answered by 8 years ago

If you mean making a GUI Visible, this should work:

local uis = game:GetService("UserInputService") -- Get the UserInputService.
local ui = script.Parent --Define ScreenGui
local frame = ui.Frame --Define Frame

uis.InputBegan:connect(function(inputObject) -- Function fires when any input from your device is recieved, where inputObject is an Instance with a Child containing information about the key, button or anything else.
    if inputObject.KeyCode == Enum.KeyCode.E then -- If statement that checks if the KeyCode is E
        frame.Visible = true
    end
end)

Read more here: http://wiki.roblox.com/index.php?title=API:Class/UserInputService/InputBegan

0
what do i put it in ? joshmatt1245 5 — 8y
0
A local script. With line 3 edited to be the path of the frame. I urge you to read this, joshmatt1245: http://wiki.roblox.com/?title=Scripting_Book Pyrondon 2089 — 8y
Ad