#What is a Good Way to Handle Inputs

11 messages · Page 1 of 1 (latest)

deft totem
#

I need help on creating a good input handling system that can check if a person is holding, releasing, etc. To any input(s). I was thinking of just creating a bool to check if the input is currently being held but idk.

#

If I don't answer I'm sleeping

red marten
#

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

rugged sedge
deft totem
#

@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

rugged sedge
#

You can use remotes

#

When player presses or releases an imput, send that to server