Progressive Jump Power Reduction

I have created a simple Progressive Jump Power Reduction system, all it does if the player jumps right after landing the next jump will become smaller than the last. However, if the player does not jump for more than a 1 second [resetTime] it will return back to default jump height.

defaultJumpPower - Default Jump Power
decrementJumpPower - If players jumps before [resetTime] the character jump power will be decreased by [decrementJumpPower]
resetTime - Time it take to reset after landing.
minJumpPower - Minimum Jump Power Allowed.

How to use:

  1. Copy the code below, and paste it in to a local script.
  2. Place the local script inside Game > StarterPlayer > StarterPlayerScripts
  3. Enjoy!

Code

-- services
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

-- constants
local PLAYER = Players.LocalPlayer
local CHARACTER = PLAYER.Character or PLAYER.CharacterAdded:wait()
local HUMANOID = CHARACTER:WaitForChild("Humanoid")

-- parameters
local defaultJumpPower = 50
local decrementJumpPower = 18
local resetTime = 1 -- time in seconds
local minJumpPower = 0 -- minimum jump power

-- flags
local isJumping = false
local timeSinceLastJump = tick()

-- Enable Jump Power
HUMANOID.UseJumpPower = true
HUMANOID.JumpPower = defaultJumpPower

-- Check and adjust Jump Power based on time since last jump
local function adjustJumpPower(dt)
	if HUMANOID:GetState() == Enum.HumanoidStateType.Jumping and not isJumping then
		isJumping = true
		if timeSinceLastJump <= resetTime and HUMANOID.JumpPower - decrementJumpPower >= minJumpPower then
			HUMANOID.JumpPower = HUMANOID.JumpPower - decrementJumpPower
		else
			HUMANOID.JumpPower = math.max(minJumpPower, HUMANOID.JumpPower)
		end
		timeSinceLastJump = 0
	elseif HUMANOID:GetState() == Enum.HumanoidStateType.Landed then
		isJumping = false
	end
	timeSinceLastJump = timeSinceLastJump + dt
	if timeSinceLastJump > resetTime then
		HUMANOID.JumpPower = defaultJumpPower
	end
end

-- Connect to RunService.Heartbeat
RunService.Heartbeat:Connect(adjustJumpPower)

7 Likes