-
What do you want to achieve?
I am making a parkour vaulting script that when you jump onto a higher platform, you are given a short window of time to press the jump button and launch up really high. -
What is the issue?
The function that changes the jump height of the player is being run, but the player never seems to exceed the default jump height. -
What solutions have you tried so far?
I’ve tried adding a RunService.Heartbeat:Wait() before and after changing the jumpheight but that didn’t seem to do anything. I think it only stopped working after I added canVault and moved the code that runs the highjump() function to the Heartbeat.
All of the code is inside a localscript.
Video of code, it’s not letting me upload videos directly to the forum: - YouTube
local players = game:GetService("Players")
local uis = game:GetService("UserInputService")
local ts = game:GetService("TweenService")
local rs = game:GetService("RunService")
local lp = players.LocalPlayer
local h = lp.Character.Humanoid
local hrp = lp.Character.HumanoidRootPart
local startY = h.Parent.HumanoidRootPart.Position.Y
local endY = h.Parent.HumanoidRootPart.Position.Y
local wantsToJump = 0
local canVault = 0
local canTry = true
function coyotejump()
if canTry == true then
wantsToJump = 0.2
canTry = false
print("coyotejump window triggered!")
end
end
function highjump()
warn("highjumping, conditions met")
h.JumpHeight = 40
h:ChangeState(Enum.HumanoidStateType.Jumping)
h.JumpHeight = 13
h.Parent.s_vault:Play() --this is a sound
end
h.Jumping:Connect(function(isActive)
if isActive == true then
print("jumped, point one set")
startY = h.Parent.HumanoidRootPart.Position.Y
end
end)
h.StateChanged:Connect(function(old, new)
if new == Enum.HumanoidStateType.Landed then
print("landed, point two set")
endY = h.Parent.HumanoidRootPart.Position.Y
canTry = true
if endY - startY > 2 then
canVault = 0.15
print("CanVault window triggered!")
end
end
end)
uis.JumpRequest:connect(coyotejump)
rs.Heartbeat:Connect(function(delta)
wantsToJump -= delta
canVault -= delta
if wantsToJump > 0 and canVault > 0 then
highjump()
wantsToJump = 0
canVault = 0
canTry = true
end
end)