I’m currently making a “super jump” which will make the player jump higher, the longer they hold the jump button.
LocalScript:
local contextActionService = game:GetService("ContextActionService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local primaryPart = character.PrimaryPart
local height = 10
local maxHeight = 50
canCrouch = true
canJump = false
local vectorForce = script:WaitForChild("VectorForce")
vectorForce.Attachment0 = primaryPart:WaitForChild("RootRigAttachment")
local crouchTrack = humanoid.Animator:LoadAnimation(script:WaitForChild("Hold"))
local jumpTrack = humanoid.Animator:LoadAnimation(script:WaitForChild("Jump"))
local function superJump(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Begin and canCrouch == true then
canCrouch = false
canJump = true
humanoid.WalkSpeed = 4
crouchTrack:Play()
repeat
task.wait(1)
if height < maxHeight then
height += 10
end
until inputState == Enum.UserInputState.End
elseif inputState == Enum.UserInputState.End and canJump == true then
canJump = false
vectorForce.Force = Vector3.new(primaryPart.CFrame.LookVector.X, height, primaryPart.CFrame.LookVector.Z) * 100
crouchTrack:Stop()
jumpTrack:Play()
humanoid.WalkSpeed = 16
height = 10
wait(1)
vectorForce.Force = Vector3.new(0,0,0)
jumpTrack:Stop()
task.wait(5)
canCrouch = true
canJump = false
end
end
contextActionService:BindAction("Jump", superJump, true, Enum.KeyCode.Space, Enum.KeyCode.ButtonA)
For some reason when I try to change the height value back to 10, it doesn’t work. Then the next time they jump, no matter how long they hold the jump button, it’s set to the previous height.
Any thoughts as to why this is happening?