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

Hotkey To Run A Certain Script In Workspace?

How do I make a hotkey script when you hit a certain key it will run a script? like say I push "e" and it runs a script to open a gui.

I know this is wrong but say

game.LocalPlayer.KeyPressed("e") then

game.workspace.Gui.Transparancy = 1

1 answer

✓ Accepted answer

Well, first of all, you would use UserInputService, there are many tutorials on it on youtube.

Let's go ahead and get the Service

game:GetService("UserInputService")

Now that we have the service, we can determine if the player has pressed a certain key (in your case "E") let's go ahead and do that

local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input,gameProcessedEvent) -- tells us if the input has began
if input.KeyCode == Enum.KeyCode.E then
-- code here
end
end)

3 comments

0

He seems like a beginner. UserInputService is not a topic for beginners but.. okay.

0

Well he asked for help, I'd rather not leave him with nothing.

0

That's one of the only ways to actually do it, doesn't matter if he's a beginner, it's fairly easy to understand. Not that advanced in the way that he's using it.

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