On my game, I want to make a key event to where if you press "c", you get down on the floor, but slower then usual.
If you want to make a function that triggers by a certain Key then I suggest you use UserInputService and a If statement.
game:GetService("UserInputService").InputBegan:connect(function(Key,Typing)--The second argument "Typing" is a Boolean value that indicates whether or not the Player is Typing. if Typing == false and Key.KeyCode == Enum.KeyCode.C then--This checks if the Player isn't Typing as well as if the C key has been pressed --YourCode end end)
~UserOnly20Charcters, Hoped I helped you to answer your question! If you have any further question, don't hesitate to comment below!!
local player = game.Players.LocalPlayer local mouse = player:GetMouse() mouse.KeyDown:connect(function(key) if key == "x" then -- change the 'x' -- do stuff end)
function keypress(UserInput, gameProcessedEvent) if UserInput.KeyCode == Enum.KeyCode.R then --YOUR CODE game:GetService("UserInputService").InputBegan:connect(keypress) end
Use UserInputService, avoid keydown since its deprecated.