Advertisement
Parallaxox

How to Double Jump

Apr 7th, 2025 (edited)
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | Help | 0 0
  1. --https://youtu.be/z0CfDQ9zy0o
  2. local UserInputService = game:GetService("UserInputService")
  3. local Players = game:GetService("Players")
  4.  
  5. local player = Players.LocalPlayer
  6. local character = player.Character or player.CharacterAdded:Wait()
  7. local humanoid = character:WaitForChild("Humanoid")
  8. local rootPart = character:WaitForChild("HumanoidRootPart")
  9.  
  10. local jumpHeight = 100
  11. local canDoubleJump = false
  12. local hasDoubleJumped = false
  13.  
  14. humanoid.StateChanged:Connect(function(_, newState)
  15.     if newState == Enum.HumanoidStateType.Landed then
  16.         canDoubleJump = false
  17.         hasDoubleJumped = false
  18.     end
  19. end)
  20.  
  21. UserInputService.InputBegan:Connect(function(input, gameProcessed)
  22.     if gameProcessed then return end
  23.  
  24.     if input.KeyCode == Enum.KeyCode.Space then
  25.         if humanoid:GetState() == Enum.HumanoidStateType.Freefall and canDoubleJump and not hasDoubleJumped then
  26.             hasDoubleJumped = true
  27.             rootPart.Velocity = Vector3.new(rootPart.Velocity.X, jumpHeight, rootPart.Velocity.Z)
  28.         elseif humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then
  29.             canDoubleJump = true
  30.         end
  31.     end
  32. end)
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement