yea so i need help sorry for the title i am still learning scripting i am a noob at it how do i detect a keyboard key pressed?
You can use the UserInputService to detect when a key is pressed. For example:
local userinputservice = game:GetService("UserInputService") userinputservice.InputBegan:Connect(function(key) -- when key is pressed if key.KeyCode == Enum.KeyCode.Q then -- if key is *x* then... --CODE end end)
I think this might help :) It shows you how to use all sorts of user input
https://developer.roblox.com/en-us/articles/introduction-to-input
You would use UserInputService to detect keys being pressed down.
local InputService = game:GetService('UserInputService') -- Gets the input service InputService.InputBegan:Connect(function(key) -- InputBegan runs when a key is pressed and the the variable 'key' will represent what was pressed if key.KeyCode = Enum.KeyCode.TheKeyYouWant then -- Checks if the key is the one you want --Code here end end)
If this helped you please mark it as answered :D
welp now i aint answering any cus i already found a MUCH shrter version