I know how to check if the player pushes a key down, but I'm not sure how to check it is is being held down. The code below is how I check if it has been pressed, but not held down.
--This will jolt the player in the direction that they are facing when they push W.
function OnPressW(actionName, userInputState, inputObject)
if userInputState == Enum.UserInputState.Begin then
script.Parent.HumanoidRootPart.BodyForce.Force =
Functions.GetRotation(player.HumanoidRootPart) * Vector3.new(0,0,1) * -40000;
end
end
game.ContextActionService:BindAction("OnPressW", OnPressW, false, Enum.KeyCode.W)

4 comments
i just hook userinputservice and set a variable to true/false when the InputBegan/InputEnded completes
I've heard that you're supposed to use ContextActionService instead for some reason.
^ you don't have to use ContextActionService but it makes it easier for making multi-platform games you can bind certain inputs from different platforms to a function
oh