Mryeetmemes

Roblox Studio C to Crouch

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