George148

crouch

May 25th, 2015
2,064
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.19 KB | None | 0 0
  1. -- By: StealthLava
  2. -- LU: [14.03.10]
  3.  
  4. --[ Setup ]--
  5. -- Locations
  6. local StealthLava = script.Parent
  7. local Player = game.Players.LocalPlayer
  8. local Avatar = Player.Character
  9. local Mouse = Player:GetMouse()
  10.  
  11. -- Emptys
  12. local Hold = nil
  13.  
  14. --[ Get Items ]--
  15. local Humanoid = Avatar:WaitForChild("Humanoid")
  16. local Torso = Avatar:WaitForChild("Torso")
  17. local RH = Torso:WaitForChild("Right Hip")
  18. local LH = Torso:WaitForChild("Left Hip")
  19.  
  20. local RL = Avatar:WaitForChild("Right Leg")
  21. local LL = Avatar:WaitForChild("Left Leg")
  22.  
  23. local RJ = Avatar:WaitForChild("HumanoidRootPart"):WaitForChild("RootJoint")
  24.  
  25. --[ Functions ]--
  26. function CreateWeld(Part, CF)
  27.     local w = Instance.new("Weld")
  28.     w.Name = "LegWeld"
  29.     w.Parent = Torso
  30.     w.Part0 = Torso
  31.     w.Part1 = Part
  32.     w.C1 = CF
  33. end
  34.  
  35. function StandUp()
  36.     Humanoid.CameraOffset = Vector3.new(0, 0, 0)
  37.     -- Right Leg
  38.     RH.Part1 = RL
  39.  
  40.     -- Left Leg
  41.     LH.Part1 = LL
  42.  
  43.     -- Delete Welds
  44.     for i, s in pairs(Torso:GetChildren()) do
  45.         if (s.Name == "LegWeld") and (s.ClassName == "Weld") then
  46.             s:Destroy()
  47.         end
  48.     end
  49.  
  50.     -- Raise Character
  51.     RJ.C0 = CFrame.new(0, 0, 0) * CFrame.Angles(0, 0, 0)
  52.     RJ.C1 = CFrame.new(0, 0, 0) * CFrame.Angles(0, 0, 0)
  53. end
  54.  
  55. --[ Hooks ]--
  56. -- Controls
  57. Mouse.KeyDown:connect(function(Key)
  58.     if (Hold ~= nil) then return end
  59.     if (string.upper(Key) ~= "C") and (string.lower(Key) ~= " ") then return end
  60.     Hold = true
  61.  
  62.     if (Torso:FindFirstChild("LegWeld") == nil) and (string.lower(Key) ~= " ") then
  63.         -- Right Leg
  64.         RH.Part1 = nil
  65.         CreateWeld(RL, CFrame.new(-0.5, 0.75, 1))
  66.  
  67.         -- Left Leg
  68.         LH.Part1 = nil
  69.         CreateWeld(LL, CFrame.new(0.5, 0.495, 1.25) * CFrame.Angles(math.rad(90), 0, 0))
  70.        
  71.         -- Lower Character
  72.         RJ.C0 = CFrame.new(0, -1.25, 0) * CFrame.Angles(0, 0, 0)
  73.         RJ.C1 = CFrame.new(0, 0, 0) * CFrame.Angles(0, 0, 0)
  74.        
  75.         -- Slow Walk Speed
  76.         Humanoid.CameraOffset = Vector3.new(0, -1.25, 0)
  77.         Humanoid.WalkSpeed = 8
  78.        
  79.     else
  80.         StandUp()
  81.  
  82.         -- Normal Walk Speed
  83.         Humanoid.CameraOffset = Vector3.new(0, 0, 0)
  84.         Humanoid.WalkSpeed = 16
  85.        
  86.     end
  87.  
  88.     wait(0.5)
  89.  
  90.     Hold = nil
  91. end)
  92.  
  93. -- Value Changed
  94. Humanoid.Changed:connect(function()
  95.     if (Humanoid.WalkSpeed > 8) and (Hold == nil) then StandUp() end
  96. end)
Advertisement
Add Comment
Please, Sign In to add comment