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

Why is this script preventing me from jumping?

Asked by 7 years ago

I was testing out stuff on my place, then I noticed that I couldn't jump. After disabling some scripts to find what was causing it, it was just this one script. Does anyone know how to stop this?

local actionservice = game:GetService("ContextActionService")
local character = game.Players.LocalPlayer.Character

function DoubleJump(actionName, actionInputState, actionInputObject)
    if character.Humanoid:GetState() == Enum.HumanoidStateType.Jumping or character.Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
        print("poof")
    end
end

actionservice:BindAction("DoubleJump", DoubleJump, false, " ")

(the script that is causing it)

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago

The space bar already has an action bound to it.. making you jump :D

You're overwriting that with code that prints if you're falling or jumping..

I would suggest using the InputBegan event of UserInputService.

local inputservice = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local hum = character:WaitForChild("Humanoid")
local jumping = Enum.HumanoidStateType.Jumping
local falling = Enum.HumanoidStateType.FreeFall

function DoubleJump(i,p)
    if not p then
        if i.KeyCode == Enum.KeyCode.Space then
            local state = hum:GetState()
            if state == jumping or state == falling then
                print("poof")
            end
        end
    end
end

inputservice.InputBegan:Connect(DoubleJump)
Ad

Answer this question