Ad
Log in to vote
0

How to jump with multiple keys?

Asked by 9 days ago
Edited 9 days ago

I want to enable jumping with multiple keys, the problem is a bug occurs where the player can infinitely jump. I don't know what is causing this problem. Here is my attempt.

local UserInputService = game:GetService("UserInputService")
local ContextActionService = game:GetService("ContextActionService")

ContextActionService:UnbindAction("jumpAction")

UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
    if input.KeyCode == Enum.KeyCode.LeftControl or  Enum.KeyCode.Space and gameProcessedEvent then
        local character = game:GetService("Players").LocalPlayer.Character

        if character then
            if character.Humanoid.Health > 0 then
                character.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
            end
        end
    end
end)

1 answer

Log in to vote
0
Answered by
eLunate 5136 Trusted Moderation Voter Community Moderator
9 days ago

You should check before letting them jump whether they are Falling via GetState

Ad

Answer this question