So in case you're wondering what I mean: like if a press the key "H" it would print Hello World.
Thank you, InfectedRythmCC
So in case you're wondering what I mean: like if a press the key "H" it would print Hello World.
Thank you, InfectedRythmCC
I suggest you reading the following articles from the wiki: https://developer.roblox.com/en-us/api-reference/event/UserInputService/InputBegan https://developer.roblox.com/en-us/api-reference/enum/KeyCode
For your example, the code would be like this: (Writen in a local script inside StarterPlayerScripts)
local UserInputService = game:GetService("UserInputService")
local hotkey = "H"
local message = "Hello world"
function OnInputBegan(input, gameProcessed)
-- Check if triggered by the keyboard
if input.UserInputType == Enum.UserInputType.Keyboard then
local keyPressed = input.KeyCode
-- Check if the key pressed was 'hotkey'
if keyPressed == Enum.KeyCode[hotkey] then
print(message)
end
end
end
UserInputService.InputBegan:Connect(OnInputBegan)
local uis = game:GetService("UserInputService")
uis.InputBegan:connect(function(key)
if key.KeyCode == Enum.Keycode.H then
print("YouTube Exists")
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
Thank you. It works great :)
No problem! Anytime :)
It would also work inside StarterPack