Advertisement
BobMe

DD

Jan 26th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. local canDoubleJump = false
  2. local hasDoubleJumped = false
  3. local oldPower
  4. local TIME_BETWEEN_JUMPS = 0.2
  5. local DOUBLE_JUMP_POWER_MULTIPLIER = 2
  6.  
  7. function onJumpRequest()
  8. if not character or not humanoid or not character:IsDescendantOf(workspace) or
  9. humanoid:GetState() == Enum.HumanoidStateType.Dead then
  10. return
  11. end
  12.  
  13. if canDoubleJump and not hasDoubleJumped then
  14. hasDoubleJumped = true
  15. humanoid.JumpPower = oldPower * DOUBLE_JUMP_POWER_MULTIPLIER
  16. humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
  17. end
  18. end
  19.  
  20. local function characterAdded(newCharacter)
  21. character = newCharacter
  22. humanoid = newCharacter:WaitForChild("Humanoid")
  23. hasDoubleJumped = false
  24. canDoubleJump = false
  25. oldPower = humanoid.JumpPower
  26.  
  27. humanoid.StateChanged:connect(function(old, new)
  28. if new == Enum.HumanoidStateType.Landed then
  29. canDoubleJump = false
  30. hasDoubleJumped = false
  31. humanoid.JumpPower = oldPower
  32. elseif new == Enum.HumanoidStateType.Freefall then
  33. wait(TIME_BETWEEN_JUMPS)
  34. canDoubleJump = true
  35. end
  36. end)
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement