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.
✓ ANSWER ACCEPTED
How to make a key event?
3 answers
✓ Accepted answer
Warning: This question could be Marked as not constructive since you have provided us with any effort of you trying to accomplish this on your own.
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)
2 comments
0
I strongly suggest that you shouldn't use KeyDown event as its Deprecated!
0
It's the 'basic' scripting, there's nothing wrong with it.
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.
1 comment
0
Do not use KeyDown it's a bad way to get key input.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Thanks :D