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
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
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
He seems like a beginner. UserInputService is not a topic for beginners but.. okay.
Well he asked for help, I'd rather not leave him with nothing.
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.