Super Jump Troubles

Hi! I’m making a super jump feature where if you hold space long enough it will increase your jump height. However I am encountering an issue. Whenever I do the super jump it doesn’t make me jump any higher than normal, however when I print what the Humanoids JumpHeight is, it is not the normal amount. Meaning that the Jump Height is increasing but the player won’t go Higher than normal.

--//Services
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

--//Instances
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

--//Data
local Jumped = false
local Charging = false

local DefWalk = Humanoid.WalkSpeed

local debounce = false

local normaljumpheight = Humanoid.JumpHeight

local Cooldown = 1.832715

local minheight = normaljumpheight
local maxheight = 270
local maxholdtime = 13

local minholdtime = 1

local lastime

local elapsedtime

local jp = normaljumpheight

--//Functions

--//Events

--//Script
UIS.InputBegan:Connect(function(input, chat)
	if chat then return end
	if input.KeyCode == Enum.KeyCode.Space and not debounce then
		Charging = true
		lastime = tick()
		while wait() do
			if Charging then
				local holdtime = tick()
				if holdtime - lastime >= minholdtime then
					print(holdtime - lastime)
					elapsedtime = holdtime - lastime
					jp = jp + 0.5
					Humanoid.JumpHeight = jp
					if jp >= maxheight then
						jp = maxheight
					end
				end
			end
		end

	end
end)

UIS.InputEnded:Connect(function(input, chat)
	if chat then return end
	if input.KeyCode == Enum.KeyCode.Space then
		Charging = false
		if elapsedtime >= minholdtime then
			Jumped = true
			if Humanoid.FloorMaterial ~= Enum.Material.Air then
				Humanoid.JumpHeight = jp
				Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
				print("Jump Height is", Humanoid.JumpHeight)
			end
			print(elapsedtime, "Has went by")
			print(jp)
			elapsedtime = 0
			jp = normaljumpheight
			Humanoid.JumpHeight = normaljumpheight
			Jumped = false
			debounce = true
			wait(Cooldown)
			debounce = false
		end
	end
end)

UIS.JumpRequest:Connect(function()
	if elapsedtime >= minholdtime then
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
	else
		if Humanoid.FloorMaterial == Enum.Material.Air then return end
		Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
	end
end)

RunService.RenderStepped:Connect(function()
	if Jumped then
		if Humanoid.FloorMaterial == Enum.Material.Air then
			Humanoid.WalkSpeed = 124
		else
			Humanoid.WalkSpeed = DefWalk
		end
	end
end)

Help would be appreciated

1 Like

Add RunService.Heartbeat:Wait() before this line. If it did not work then just add a wait(0.1).

Try increasing JumpPower instead.

It worked! But now it’s not increasing their walkspeed while they are jumping for some reason