Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does my double jump script fails sometimes?

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.