Advertisement
Donny526

Crouch script for script builder

Jul 3rd, 2018
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.38 KB | None | 0 0
  1. -- ReUploaded to Script Builder by Donny526 --
  2. -- Not my creation --
  3. -- Donny526#1886 --
  4.  
  5. repeat wait() until game.Players.LocalPlayer.Character
  6. repeat wait(1) until game.Players.LocalPlayer.Character:IsDescendantOf(game.Workspace)
  7. wait(4 / 20)
  8.  
  9. local Player = game.Players.LocalPlayer
  10. local player = game.Players.LocalPlayer
  11. local Character = Player.Character
  12. local char = Player.Character
  13. local Humanoid = Character.Humanoid
  14. local Mouse = Player:GetMouse()
  15. local mouse = Player:GetMouse()
  16.  
  17. local Camera = game.Workspace.CurrentCamera
  18.  
  19. local HumanoidRootPart = Character.HumanoidRootPart
  20.  
  21. local Torso = Character.Torso
  22. local Neck = Torso:WaitForChild("Neck")
  23.  
  24. game.Players.LocalPlayer.CameraMaxZoomDistance = 15
  25. game.Players.LocalPlayer.CameraMinZoomDistance = 0
  26.  
  27. local NightVision = false
  28.  
  29.  
  30. local AltPressed = false
  31.  
  32. local Stances = 0
  33. _G.SteadyStance = false
  34. _G.LeanR = 0
  35. _G.LeanL = 0
  36.  
  37. local RAW
  38. local LAW
  39. ----------------
  40. local RootPart = char:WaitForChild("HumanoidRootPart")
  41. local RootJoint = RootPart.RootJoint
  42. RootJoint.C0 = CFrame.new()
  43. RootJoint.C1 = CFrame.new()
  44.  
  45. local Aiming = false
  46.  
  47. local ZoomDistance = 40
  48.  
  49. local NV
  50.  
  51. ----------------
  52.  
  53. ---------------------------------------------------------------------------------------
  54. ---------------- [ Tween Module ] --------------------------------------------------------
  55. ---------------------------------------------------------------------------------------
  56.  
  57.  
  58. --[[
  59.  
  60. tweenJoint Function Parameters:
  61.  
  62. Object Joint - This has to be a weld with a C0 and C1 property
  63.  
  64. CFrame newC0 - This is what the new C0 of the weld will be. You can put nil if you don't want to effect the C0
  65.  
  66. CFrame newC1 - This is what the new C1 of the weld will be. You can put nil if you don't want to effect the C1
  67.  
  68. function Alpha - This is an alpha function that takes an input parameter of a number between 0 and 90 and returns a number between 0 and 1.
  69. For example, function(X) return math.sin(math.rad(X)) end
  70.  
  71. float Duration - This is how long the tweening takes to complete
  72.  
  73. --]]
  74. local RS = game:GetService("RunService")
  75.  
  76.  
  77.  
  78. function tweenJoint(Joint, newC0, newC1, Alpha, Duration)
  79. spawn(function()
  80. local newCode = math.random(-1e9, 1e9) --This creates a random code between -1000000000 and 1000000000
  81. local tweenIndicator = nil
  82. if (not Joint:findFirstChild("tweenCode")) then --If the joint isn't being tweened, then
  83. tweenIndicator = Instance.new("IntValue")
  84. tweenIndicator.Name = "tweenCode"
  85. tweenIndicator.Value = newCode
  86. tweenIndicator.Parent = Joint
  87. else
  88. tweenIndicator = Joint.tweenCode
  89. tweenIndicator.Value = newCode --If the joint is already being tweened, this will change the code, and the tween loop will stop
  90. end
  91. if Duration <= 0 then --If the duration is less than or equal to 0 then there's no need for a tweening loop
  92. if newC0 then Joint.C0 = newC0 end
  93. if newC1 then Joint.C1 = newC1 end
  94. else
  95. local Increment = 1.5 / Duration --Calculate the increment here so it doesn't need to be calculated in the loop
  96. local startC0 = Joint.C0
  97. local startC1 = Joint.C1
  98. local X = 0
  99. while true do
  100. RS.RenderStepped:wait() --This makes the for loop step every 1/60th of a second
  101. local newX = X + Increment
  102. X = (newX > 90 and 90 or newX) --Makes sure the X never goes above 90
  103. if tweenIndicator.Value ~= newCode then break end --This makes sure that another tween wasn't called on the same joint
  104. if newC0 then Joint.C0 = startC0:lerp(newC0, Alpha(X)) end
  105. if newC1 then Joint.C1 = startC1:lerp(newC1, Alpha(X)) end
  106. if X == 90 then break end --If the tweening is done...
  107. end
  108. end
  109. if tweenIndicator.Value == newCode then --If this tween functions was the last one called on a joint then it will remove the code
  110. tweenIndicator:Destroy()
  111. end
  112. end)
  113. end
  114.  
  115. function CreateWeld(Part, CF)
  116. local w = Instance.new("Weld")
  117. w.Name = "LegWeld"
  118. w.Parent = Torso
  119. w.Part0 = Torso
  120. w.Part1 = Part
  121.  
  122. tweenJoint(w, nil, CF, function(X) return math.sin(math.rad(X)) end, 0.25)
  123. end
  124.  
  125. ----------------------------------------------
  126. local RS = Torso["Right Shoulder"]
  127. local LS = Torso["Left Shoulder"]
  128. local RH = char["Torso"]:WaitForChild("Right Hip")
  129. local LH = char["Torso"]:WaitForChild("Left Hip")
  130. local LeftLeg = char["Left Leg"]
  131. local RightLeg = char["Right Leg"]
  132. local Proned2
  133.  
  134.  
  135.  
  136. function TweenCOffset(CO, t)
  137. coroutine.resume(coroutine.create(function()
  138. COn = COn and COn + 1 or 0 local COn_S = COn
  139. for i = 1, t do
  140. if COn ~= COn_S then break end
  141. char.Humanoid.CameraOffset = char.Humanoid.CameraOffset + (CO - char.Humanoid.CameraOffset) * (i / t)
  142. game:GetService("RunService").RenderStepped:wait()
  143. end
  144. end))
  145. end
  146.  
  147. function TweenTransparency(Part,Trans, t)
  148. coroutine.resume(coroutine.create(function()
  149. COn = COn and COn + 1 or 0 local COn_S = COn
  150. for i = 1, t do
  151. if COn ~= COn_S then break end
  152. Part.Transparency = Part.Transparency + (Trans - Part.Transparency) * (i / t)
  153. game:GetService("RunService").RenderStepped:wait()
  154. end
  155. end))
  156. end
  157.  
  158. function TweenColor(Part,Color, t)
  159. coroutine.resume(coroutine.create(function()
  160. COn = COn and COn + 1 or 0 local COn_S = COn
  161. for i = 1, t do
  162. if COn ~= COn_S then break end
  163. Part.BrickColor = Part.BrickColor + (Color - Part.BrickColor) * (i / t)
  164. game:GetService("RunService").RenderStepped:wait()
  165. end
  166. end))
  167. end
  168.  
  169. function Stand()
  170.  
  171. TweenCOffset(Vector3.new(0,0,0), 20)
  172. Humanoid.WalkSpeed = 16
  173. Humanoid.JumpPower = 50
  174.  
  175. IsStanced = false
  176.  
  177. LH.Part1 = LeftLeg
  178. RH.Part1 = RightLeg
  179.  
  180. Proned2 = Vector3.new(0,0,0)
  181. tweenJoint(RootJoint, CFrame.new()* CFrame.Angles(math.rad(-0),0,math.rad(0)), CFrame.new(0,0,0), function(X) return math.sin(math.rad(X)) end, 0.25)
  182. tweenJoint(RH, CFrame.new(1,-1,0)* CFrame.Angles(math.rad(-0),math.rad(90),math.rad(0)), nil, function(X) return math.sin(math.rad(X)) end, 0.25)
  183. tweenJoint(LH, CFrame.new(-1,-1,0)* CFrame.Angles(math.rad(-0),math.rad(-90),math.rad(0)), nil, function(X) return math.sin(math.rad(X)) end, 0.25)
  184. tweenJoint(RS, CFrame.new(1,0.5,0)* CFrame.Angles(math.rad(0),math.rad(90),math.rad(0)), nil, function(X) return math.sin(math.rad(X)) end, 0.25)
  185. tweenJoint(LS, CFrame.new(-1,0.5,0)* CFrame.Angles(math.rad(0),math.rad(-90),math.rad(0)), nil, function(X) return math.sin(math.rad(X)) end, 0.25)
  186. for i, s in pairs(Torso:GetChildren()) do
  187. if (s.Name == "LegWeld") and (s.ClassName == "Weld") then
  188. s:Destroy()
  189. end
  190. end
  191. end
  192.  
  193. function StandEquip()
  194.  
  195. TweenCOffset(Vector3.new(0,0,0), 20)
  196. Humanoid.WalkSpeed = 12
  197. Humanoid.JumpPower = 30
  198. IsStanced = false
  199.  
  200. LH.Part1 = LeftLeg
  201. RH.Part1 = RightLeg
  202.  
  203. Proned2 = Vector3.new(0,0,0)
  204. tweenJoint(RootJoint, CFrame.new(0,0,0.275)* CFrame.Angles(math.rad(-10),0,math.rad(0)), CFrame.new(0,0,0), function(X) return math.sin(math.rad(X)) end, 0.25)
  205. tweenJoint(RH, CFrame.new(1,-1,-0.15)* CFrame.Angles(math.rad(20),math.rad(90),math.rad(0)), nil, function(X) return math.sin(math.rad(X)) end, 0.25)
  206. tweenJoint(LH, CFrame.new(-1,-1,-0.2)* CFrame.Angles(math.rad(-10),math.rad(-90),math.rad(0)), nil, function(X) return math.sin(math.rad(X)) end, 0.25)
  207. tweenJoint(RS, CFrame.new(1,0.5,0)* CFrame.Angles(math.rad(0),math.rad(90),math.rad(0)), nil, function(X) return math.sin(math.rad(X)) end, 0.25)
  208. tweenJoint(LS, CFrame.new(-1,0.5,0)* CFrame.Angles(math.rad(0),math.rad(-90),math.rad(0)), nil, function(X) return math.sin(math.rad(X)) end, 0.25)
  209. for i, s in pairs(Torso:GetChildren()) do
  210. if (s.Name == "LegWeld") and (s.ClassName == "Weld") then
  211. s:Destroy()
  212. end
  213. end
  214.  
  215. end
  216.  
  217.  
  218.  
  219. function Crouch()
  220.  
  221. TweenCOffset(Vector3.new(0, -1,0), 20)
  222. Humanoid.WalkSpeed = 8
  223. Humanoid.JumpPower = 10
  224. for i, s in pairs(Torso:GetChildren()) do
  225. if (s.Name == "LegWeld") and (s.ClassName == "Weld") then
  226. s:Destroy()
  227. end
  228. end
  229. IsStanced = true
  230. RH.Part1 = RightLeg
  231. LH.Part1 = LeftLeg
  232. Proned2 = Vector3.new(0,0,0)
  233. tweenJoint(RootJoint, CFrame.new(0,-1,0.25)* CFrame.Angles(math.rad(-10),0,math.rad(0)), CFrame.new(0,0,0), function(X) return math.sin(math.rad(X)) end, 0.25)
  234. tweenJoint(RH, CFrame.new(1,-0.35,-0.65)* CFrame.Angles(math.rad(-20),math.rad(90),math.rad(0)), nil, function(X) return math.sin(math.rad(X)) end, 0.25)
  235. tweenJoint(LH, CFrame.new(-1,-1.25,-0.625)* CFrame.Angles(math.rad(-60),math.rad(-90),math.rad(0)), nil, function(X) return math.sin(math.rad(X)) end, 0.25)
  236. tweenJoint(RS, CFrame.new(1,0.5,0)* CFrame.Angles(math.rad(0),math.rad(90),math.rad(0)), nil, function(X) return math.sin(math.rad(X)) end, 0.25)
  237. tweenJoint(LS, CFrame.new(-1,0.5,0)* CFrame.Angles(math.rad(0),math.rad(-90),math.rad(0)), nil, function(X) return math.sin(math.rad(X)) end, 0.25)
  238.  
  239. end
  240.  
  241. function Prone()
  242.  
  243. TweenCOffset(Vector3.new(0, -3.25, 0), 20)
  244. Humanoid.WalkSpeed = 4
  245. Humanoid.JumpPower = 0
  246. IsStanced = true
  247. RH.Part1 = nil
  248. LH.Part1 = nil
  249. Proned2 = Vector3.new(0,0.5,0.5)
  250. tweenJoint(RootJoint, CFrame.new(0,-2.5,1.35)* CFrame.Angles(math.rad(-90),0,math.rad(0)), nil, function(X) return math.sin(math.rad(X)) end, 0.25)
  251. tweenJoint(RS, CFrame.new(0.9,1.1,0)* CFrame.Angles(math.rad(-180),math.rad(90),math.rad(0)), nil, function(X) return math.sin(math.rad(X)) end, 0.25)
  252. tweenJoint(LS, CFrame.new(-0.9,1.1,0)* CFrame.Angles(math.rad(-180),math.rad(-90),math.rad(0)), nil, function(X) return math.sin(math.rad(X)) end, 0.25)
  253.  
  254. CreateWeld(RightLeg, CFrame.new(-0.2,1.85,0)* CFrame.Angles(math.rad(-0),0,math.rad(-20)))
  255. CreateWeld(LeftLeg, CFrame.new(0.2,1.85,0)* CFrame.Angles(math.rad(-0),0,math.rad(20)))
  256. end
  257.  
  258. local AlreadyProned = false
  259.  
  260. mouse.KeyDown:connect(function(Key)
  261. if Key == "c" and Stances == 0 and not _G.Sprinting and not _G.Lean then
  262. Stances = 1
  263. Crouch()
  264.  
  265. _G.Crouched = true
  266. elseif Key == "c" and Stances == 1 and not _G.Sprinting and not _G.Lean then
  267. Stances = 2
  268. Prone()
  269.  
  270. _G.Crouched = false
  271. _G.Proned = true
  272.  
  273. elseif Key == "x" and Stances == 2 and not _G.Sprinting and not _G.Lean then
  274. _G.Crouched = true
  275. _G.Proned = false
  276. Stances = 1
  277. Crouch()
  278.  
  279.  
  280. elseif Key == "x" and Stances == 1 and not _G.Sprinting and not _G.Lean then
  281. _G.Crouched = false
  282.  
  283.  
  284. Stances = 0
  285. if not _G.SteadyStance then
  286. Stand()
  287. elseif _G.SteadyStance then
  288. StandEquip()
  289. end
  290.  
  291. end
  292.  
  293. if Key == "z" and not _G.SteadyStance and Stances == 0 then
  294. if not _G.Lean and Stances == 0 then
  295. StandEquip()
  296. end
  297. _G.SteadyStance = true
  298. elseif Key == "z" and _G.SteadyStance and Stances == 0 then
  299. if not _G.Lean and Stances == 0 then
  300. Stand()
  301.  
  302. end
  303. _G.SteadyStance = false
  304. end
  305.  
  306. if Key:byte() == 308 or Key:byte() == 307 then
  307. AltPressed = true
  308. print("Alt pressed")
  309. end
  310.  
  311.  
  312. end)
  313.  
  314. mouse.KeyUp:connect(function(Key)
  315. if Key:byte() == 308 then
  316. AltPressed = false
  317. end
  318. end)
  319.  
  320. Stand()
  321.  
  322. -------------Motor6Ding Section------------------------
  323.  
  324.  
  325.  
  326.  
  327.  
  328. game:GetService("RunService").RenderStepped:connect(function()
  329. Mouse.TargetFilter = game.Workspace
  330.  
  331.  
  332. if Aiming then
  333. game:GetService('UserInputService').MouseDeltaSensitivity = Player.PlayerGui:WaitForChild("ScreenGui").Frame.Sensitivity.Text
  334. else
  335. game:GetService('UserInputService').MouseDeltaSensitivity = 1
  336. end
  337.  
  338. Mouse.Button2Down:connect(function()
  339. if not Aiming then
  340. Aiming = true
  341. end
  342. end)
  343. Mouse.Button2Up:connect(function()
  344. if Aiming then
  345. Aiming = false
  346. end
  347. end)
  348.  
  349. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement