Advertisement
Guest User

FE2 Wall Jump Script by Michael228p

a guest
Apr 13th, 2019
9,132
1
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.31 KB | None | 1 0
  1. --VARIABLES
  2. --Services
  3. local RS = game:GetService("RunService")
  4. local UIS = game:GetService("UserInputService")
  5. local CAS = game:GetService("ContextActionService")
  6. local char = script.Parent
  7. local HumRtPt = script.Parent:WaitForChild("HumanoidRootPart")
  8. local Hum = script.Parent:WaitForChild("Humanoid")
  9.  
  10. --Local variables
  11. local debouce = false
  12. local keydebouce = false
  13. local walljumping = false
  14.  
  15.  
  16. --Predefined local variables
  17. local weld
  18.  
  19. --Audios
  20. local _Off = script:WaitForChild("_Off")
  21. local _Hit = script:WaitForChild("_Hit")
  22.  
  23. --Predefined connection variables
  24. local jumpConnection
  25. local runConnection
  26.  
  27. --Functions
  28. function WaitFunc(s)
  29.     local counter = false
  30.     delay(s,function()
  31.         counter = true
  32.     end)
  33.     repeat wait() until counter
  34.     return true
  35. end
  36.  
  37. --Animation
  38. local animationInstance = Instance.new("Animation", HumRtPt)
  39. animationInstance.AnimationId = "rbxassetid://3038214797"
  40. local animation = Hum:LoadAnimation(animationInstance)
  41.  
  42. function WallJumpEvent(part)
  43.     local objV = part:FindFirstChild("_Wall") -- Check if this part is a wall-jump part
  44.     if objV then
  45.        
  46.         if objV:IsA("ObjectValue") then
  47.            
  48.             local ray = Ray.new(HumRtPt.Position, HumRtPt.CFrame.LookVector.Unit *2) -- Check if angle is close
  49.             local raypart, pos, normal = workspace:FindPartOnRay(ray,char)
  50.            
  51.             if raypart == part and not debouce then
  52.  
  53.                 walljumping = true -- Take effects
  54.                 debouce = true
  55.                 char.Humanoid.WalkSpeed = 0
  56.                 HumRtPt.CFrame = CFrame.new(HumRtPt.CFrame.p, HumRtPt.CFrame.p+normal)
  57.            
  58.                 if part:IsDescendantOf(workspace.Lobby) then -- Check if the wall-jump part is the one in the lobby
  59.                     part.BrickColor = BrickColor.Red()
  60.                 end
  61.                
  62.                 weld = Instance.new("WeldConstraint",HumRtPt) -- Make character stick by the wall
  63.                 weld.Part0 = HumRtPt
  64.                 weld.Part1 = part
  65.                 _Hit:Play()
  66.                 animation:Play()
  67.                                
  68.                 local timer = 0.7           -- Wait until Space key is press (with debouce) OR after 0.7 seconds
  69.                 local starttime = tick()
  70.                 local remainingtime = 0.7
  71.                
  72.                 repeat wait() remainingtime = 0.7 - (tick() - starttime) print(remainingtime) until not UIS:IsKeyDown(Enum.KeyCode.Space) or remainingtime <= 0
  73.                
  74.                 repeat wait() remainingtime = 0.7 - (tick() - starttime) until UIS:IsKeyDown(Enum.KeyCode.Space) or remainingtime <= 0
  75.                
  76.                 print("ended")
  77.                
  78.                 walljumping = false
  79.                
  80.                 pcall(function()
  81.                     jumpConnection:Disconnect()
  82.                 end)
  83.                
  84.                 if part:IsDescendantOf(workspace.Lobby) then
  85.                     part.BrickColor = BrickColor.Gray()
  86.                 end
  87.                                
  88.                 if UIS:IsKeyDown(Enum.KeyCode.Space) and remainingtime > 0 then -- Check if player pressed space during wall jumping
  89.                    
  90.                     game.Debris:AddItem(weld,0)                 -- take effects
  91.                     char.Humanoid.WalkSpeed = 20
  92.                     HumRtPt.Velocity = HumRtPt.CFrame.LookVector*55 +Vector3.new(0, char.Humanoid.JumpPower, 0)
  93.                     animation:Stop()
  94.                     _Off:Play()
  95.                    
  96.                     delay(0.2,function()
  97.                         part.Velocity = Vector3.new(0,0,0)
  98.                         debouce = false
  99.                     end)
  100.                    
  101.                 else
  102.                    
  103.                     game.Debris:AddItem(weld,0)
  104.                     char.Humanoid.WalkSpeed = 20
  105.                     HumRtPt.Velocity = HumRtPt.CFrame.LookVector*10
  106.                    
  107.                     delay(0.2,function()
  108.                         debouce = false
  109.                     end)
  110.                    
  111.                 end            
  112.             end
  113.         end
  114.     end
  115. end
  116.  
  117.  
  118.  
  119. HumRtPt.Touched:Connect(function(part)
  120.     WallJumpEvent(part)
  121. end)
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement