#What is a Good Way to Handle Inputs
11 messages · Page 1 of 1 (latest)
You can use User Input Service for this
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input, processed)
--key pressed
end)
UIS.InputEnded:Connect(function(input, processed)
--key released
end)
For instance, to check if the space key is pressed
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.Space and not processed then
-- function on pressed
end
end)
UIS.InputEnded:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.Space and not processed then
-- function on released
end
end)
If you want the player to hold, start a function at InputBegan and end it at InputEnded
Use ContextActionService in my opinion it's more convenient than User input service
https://create.roblox.com/docs/reference/engine/classes/ContextActionService
Yep another option
@rugged sedge @red marten I should've elaborated a bit more, I need help handling inputs in a way the server can see which player is hjolding and not holding a key