Advertisement
Markjac

Roblox Double Jump

Nov 22nd, 2016
6,156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 KB | None | 0 0
  1. --To you this script make a local script and put it in starterGUI
  2.  
  3. --[[
  4.     Put me in StarterGui or StarterPack :)
  5. ]]
  6. local Player = game.Players.LocalPlayer
  7. repeat wait() until Player.Character -- Yield until the Player's Character is no longer nil
  8. local Character = Player.Character
  9. local Humanoid = Character:WaitForChild("Humanoid")
  10. local UserInputService = game:GetService("UserInputService")
  11. local currentJump
  12. local debounce = true
  13. local DoubleJumpVelocity = 100 -- 50 is a normal ROBLOX jump
  14.  
  15. function jumpRayDown()
  16.     local nR = Ray.new(Character.Torso.Position,Vector3.new(0,-1,0).unit*4)
  17.     local hR,pR=game.Workspace:FindPartOnRay(nR,Character)
  18.     if hR~=nil then
  19.         return true
  20.     end
  21.     return false
  22. end
  23.  
  24. Humanoid.Changed:connect(
  25.     function(Property)
  26.         if Property == "Jump" and debounce == true and Humanoid.Sit==false then
  27.             currentJump=true
  28.             debounce = false
  29.             newConnection = Player:GetMouse().KeyDown:connect(function(key)
  30.                 if key:lower():byte()==32 and currentJump and Character.Torso.Velocity.y>-30 then
  31.                     currentJump=false
  32.                     for i, v in pairs(Character:GetChildren()) do
  33.                         if v:isA("BasePart") then
  34.                             v.Velocity = Vector3.new(v.Velocity.x,DoubleJumpVelocity,v.Velocity.z)
  35.                         end
  36.                     end
  37.                 end
  38.             end)
  39.             spawn(function()
  40.                 repeat wait() until jumpRayDown()==true
  41.                 debounce = true
  42.                 currentJump = false
  43.                 if type(newConnection)=="function" then
  44.                     newConnection:disconnect()
  45.                 end
  46.             end)
  47.         elseif Property == "Jump" and Humanoid.Sit==true then
  48.             Humanoid.Jump=false
  49.         end
  50.     end
  51. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement