Making Double Jump Game Pass

Making Double Jump Game Pass for Your Game

Hello everyone! May be some of you know how to make this but I’ll still make this for beginners. This is also my first tutorial. Let’s get into it!

  1. Add Script inside the ServerScriptService
    Basically add script and rename it to DoubleJump. Renaming is optional but name will help know what script it is.

  2. Type this inside the script
    I already include the explanations inside the script. Copy this script:

local id = 0 -- change this to your game pass ID

game.Players.PlayerAdded:Connect(function(plr) -- player joined the game
	plr.CharacterAdded:connect(function(char)
		if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then -- will check if player owned the game pass
			local DbJump = script.DoubleJump:Clone() -- "DoubleJump" will be a local script under this script. That local script will duplicate it
			DbJump.Parent = plr.Backpack -- will bring the local script to your property which means you can use it
		end
	end)
end)
  1. Add LocalScript inside the DoubleJump or the Script we added at the first step
    Add a LocalScript under the DoubleJump script and rename it to DoubleJump. We will use same name for each script. If you want to change the name of LocalScript, make sure that you will also change the DoubleJump in the script
Drop Down

Example:
If you rename the LocalScript into DJScript then you have to change the part of the script into

local DbJump = script.DJScript:Clone()

or just leave the name LocalScript

local DbJump = script.LocalScript:Clone()
  1. Type this inside the LocalScript
    Explanations included inside the script. Copy this:
local UserInputService = game:GetService("UserInputService")
local localPlayer = game.Players.LocalPlayer
local character
local humanoid
 
local canDoubleJump = false -- set into normal. Players cannot double jump
local hasDoubleJumped = false -- will checked if player has double jumped. Set into normal which players cannot double jump
local TBJ = 0.2 -- TBJ = time before jump. Leave the number into 0.2 or else it will stop you from double jumping
local JumpMultiplier = 1.3 -- will make the player jump 30% after the first jump

function onJumpRequest()
	if not character or not humanoid or not character:IsDescendantOf(workspace) or
	 humanoid:GetState() == Enum.HumanoidStateType.Dead then
		return
	end
 
	if canDoubleJump and not hasDoubleJumped then
		hasDoubleJumped = true -- if player only click the space bar once, it will allow the player click the space bar again to allow them to jump twice
		humanoid.JumpPower = oldPower * JumpMultiplier -- will multiply 1.3 to your jump power to let you jump higher
		humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
	end
end
 
local function characterAdded(newCharacter)
	character = newCharacter
	humanoid = newCharacter:WaitForChild("Humanoid")
	hasDoubleJumped = false
	canDoubleJump = false
	oldPower = humanoid.JumpPower 
	humanoid.StateChanged:connect(function(old, new)
		if new == Enum.HumanoidStateType.Landed then -- if the player is not jumping, then it will set into normal
			canDoubleJump = false
			hasDoubleJumped = false
			humanoid.JumpPower = oldPower		
		elseif new == Enum.HumanoidStateType.Freefall then
			wait(TBJ)			
			canDoubleJump = true
		end
	end)
end
 
if localPlayer.Character then
	characterAdded(localPlayer.Character)
end
 
localPlayer.CharacterAdded:connect(characterAdded)
UserInputService.JumpRequest:connect(onJumpRequest)

The script must be look like this:
image

There you go! You finished the tutorial!

Congratulations!

10 Likes

UserOwnsGamePassAsync can throw an error, so you’d also want to wrap this in a pcall with retrying logic.

2 Likes