Advertisement
GaryScripts

Ledge Climbing Engine for Roblox

Jan 3rd, 2021
1,371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.82 KB | None | 0 0
  1. local plr = game.Players.LocalPlayer
  2. local Character = plr.Character or plr.CharacterAdded:Wait()
  3. local Root = Character:WaitForChild("HumanoidRootPart")
  4. local Head = Character:WaitForChild("Head")
  5. local Hum = Character:WaitForChild("Humanoid")
  6. local CA = Hum:LoadAnimation(script:WaitForChild("ClimbAnim"))
  7. local HA = Hum:LoadAnimation(script:WaitForChild("HoldAnim"))
  8. local TouchGui = plr:WaitForChild("PlayerGui"):FindFirstChild("TouchGui")
  9. local UIS = game:GetService("UserInputService")
  10.  
  11. ledgeavailable = true
  12. holding = false
  13.  
  14. while game:GetService("RunService").Heartbeat:Wait() do
  15.     local r = Ray.new(Head.CFrame.p, Head.CFrame.LookVector * 5)
  16.     local part,position = workspace:FindPartOnRay(r,Character)
  17.    
  18.     if part and ledgeavailable and not holding then
  19.         if part.Size.Y >= 7 then
  20.             if Head.Position.Y >= (part.Position.Y + (part.Size.Y / 2)) - 1 and Head.Position.Y <= part.Position.Y + (part.Size.Y / 2) and Hum.FloorMaterial == Enum.Material.Air and Root.Velocity.Y <= 0 then
  21.                 Root.Anchored = true holding = true HA:Play() ledgeavailable = false
  22.             end
  23.         end
  24.     end
  25.    
  26.     function climb()
  27.         local Vele = Instance.new("BodyVelocity",Root)
  28.         Root.Anchored = false
  29.         Vele.MaxForce = Vector3.new(1,1,1) * math.huge
  30.         Vele.Velocity = Root.CFrame.LookVector * 10 + Vector3.new(0,30,0)
  31.         HA:Stop() CA:Play()
  32.         game.Debris:AddItem(Vele,.15)
  33.         holding = false
  34.         wait(.35)--depends with your animation length for the climb animation
  35.         ledgeavailable = true
  36.         CA:Stop()
  37.     end
  38.    
  39.     UIS.InputBegan:Connect(function(Key,Chat)
  40.         if not holding then return end
  41.         if Key.KeyCode == Enum.KeyCode.Space and not Chat then
  42.             climb()
  43.         end
  44.     end)
  45.    
  46.     if TouchGui then
  47.         TouchGui:WaitForChild("TouchControlFrame"):WaitForChild("JumpButton").MouseButton1Click:Connect(function()
  48.             if not holding then return end climb()
  49.         end)
  50.     end
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement