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

Why does my double jump script fails sometimes?

Asked by 7 years ago

Sometimes it works, sometimes it completely fails....there are no errors in output please help.

local Player = game.Players.LocalPlayer

while not Player.Character do
    wait()
end

local character = Player.Character
local mouse = Player:GetMouse()
local humanoid = character:WaitForChild("Humanoid")
local torso = character:WaitForChild("Torso")
local head = character:WaitForChild("Head")
local debounce = true
local ValueStorage = Player:WaitForChild("ValueStorage")
local Stamina = character:WaitForChild("Stamina")

game:GetService("UserInputService").InputBegan:connect(function(key)
    if key.KeyCode == Enum.KeyCode.Space then                                                            
        if humanoid.Jump == true then                                               
            if debounce == false then 
                return 
            end

            debounce = false
            local torso = character:FindFirstChild("Torso")

            if torso and Stamina.Value >= 50 then
                torso.Velocity = Vector3.new(torso.Velocity.X, humanoid.JumpPower * 1.3, torso.Velocity.Z)
                Stamina.Value = Stamina.Value - 50
            end
        end                                     

    repeat wait() until humanoid.Jump == false or humanoid:GetState() == Enum.HumanoidStateType.Landed
    wait(0.2)
    debounce = true
    end
end)

1 answer

Log in to vote
1
Answered by 7 years ago

I don't know. Everything looks fine too me. Must be a roblox glitch.

Ad

Answer this question