Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Do I Do A Key Pressed Function?

Asked by 5 years ago

i'm Making A Ship That If Player Is Seated And Is Pressing Key "Something" So It Moves

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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.

0
is there any other way? mkhamster 58 — 5y
2
you should not use another way, UserInputService is the best way to gather input from the client currently SaltyPotter 362 — 5y
0
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 clc02 553 — 5y
0
alright thank you! mkhamster 58 — 5y
Ad

Answer this question