i'm Making A Ship That If Player Is Seated And Is Pressing Key "Something" So It Moves
✓ ANSWER ACCEPTED
How Do I Do A Key Pressed Function?
1 answer
✓ Accepted answer
You should use UserInputService as KeyDown event is deprecated.
local uis = game:GetService:("UserInputService")
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.input.KeyCode.F then-- replace F with whatever key you'd like
print("hi")
end)
UserInputService is recommended for client input because of it's wide range of uses across multiple platforms.
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
is there any other way?
you should not use another way, UserInputService is the best way to gather input from the client currently
But, if you were going to: https://developer.roblox.com/api-reference/event/Mouse/KeyDown but be aware that it doesn't work with all keys
alright thank you!