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

How do I make double jump but only for the player that touches a certain part?

Asked by 4 years ago

How do I make double jump but only for the player that touches a certain part? this is the script I found for double jumping but it allows all players to double jump.

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

local uis = game:GetService("UserInputService")

local canDoubleJump = false
local hasLanded = true


humanoid.StateChanged:Connect(function(previous, new)

    if new == Enum.HumanoidStateType.Jumping and hasLanded then

        if not canDoubleJump then canDoubleJump = true; hasLanded = false end


    elseif new == Enum.HumanoidStateType.Landed then

        canDoubleJump = false
        hasLanded = true
    end
end)

uis.InputBegan:Connect(function(input, processed)

    if processed then return end

    if input.KeyCode == Enum.KeyCode.Space then

        if canDoubleJump then

            humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
            canDoubleJump = false
        end 
    end
end)

1 answer

Log in to vote
0
Answered by 4 years ago

im sorry, you cant request someone to write a script for you. Here is the tips

You need to set your jumping script -> script.Disabled = true if your jumping script is inside the character then this script will work

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local character = hit.Parent
        character.Script.Disabled = false --Your jumping script
    end
end)

let me know if it helps

Ad

Answer this question