Advertisement
Guest User

Parkour & Tec99 Gun (2 in 1)

a guest
Mar 23rd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 88.51 KB | None | 0 0
  1. local player = game:service("Players").LocalPlayer
  2. local mouse = player:GetMouse()
  3. local cam = workspace.CurrentCamera
  4. local char = player.Character
  5. local Torsoz = char:findFirstChild("Torso")
  6. local RA = char:findFirstChild("Right Arm")
  7. local LA = char:findFirstChild("Left Arm")
  8. local RL = char:findFirstChild("Right Leg")
  9. local LL = char:findFirstChild("Left Leg")
  10. local H = char:findFirstChild("Head")
  11. local Hu = char:findFirstChild("Humanoid")
  12. local RS = Torsoz:findFirstChild("Right Shoulder")
  13. local LS = Torsoz:findFirstChild("Left Shoulder")
  14. local RH = Torsoz:findFirstChild("Right Hip")
  15. local LH = Torsoz:findFirstChild("Left Hip")
  16. local N = Torsoz:findFirstChild("Neck")
  17. local NV = Vector3.new(0,0,0)
  18. local FOV = 70
  19. local Shift, Space, Sitting = false,false,false
  20. local GravPoint = 0
  21. local Diving = false
  22. local DivingCooldown = 0
  23. local DivingDir = NV
  24. local DivingCF = CFrame.new(0,0,0)
  25. local DivingBG, DivingBV
  26. local HWallRunning = false
  27. local HWRGravDrop = false
  28. local HWRLastPart
  29. local HWRCooldown = 0
  30. local HWRDir
  31. local VWallRunning = false
  32. local VWRLastPart
  33. local VWRCooldown = 0
  34. local VWRLeft,VWRRight = false,false
  35. local Sliding = false
  36. local SlideCooldown = 0
  37. local Standing = true
  38. local Action = "Standing"
  39. local animplus = true
  40. local animspeed = 0
  41. local animangle = 0.01
  42. local Joint1, Joint2, Joint3, Joint4, Joint5
  43.  
  44. for i, v in pairs(char:children()) do
  45. if (v.className == "LocalScript" and v.Name == "ParkourSkrip") or v.className == "NumberValue" or v.className == "BoolValue" or v.className == "Model" or v.Name == "Animate" then
  46. v:remove()
  47. end
  48. end
  49.  
  50. local loadids = {112474909, 112474911, 112474909}
  51.  
  52. local stamina = 10000
  53. local maxstamina = 10000
  54. local defsprint = 28
  55. local sprint = defsprint
  56.  
  57. local pause = Instance.new("BoolValue", char)
  58. pause.Name = "Pause"
  59. pause.Value = false
  60. local flow = Instance.new("NumberValue", char)
  61. flow.Name = "Flow"
  62. flow.Value = 0
  63. local flowcooldown = 0
  64.  
  65. local m = Instance.new("Model", char)
  66. m.Name = "FlowChainPartz"
  67.  
  68. local P = Instance.new("Part")
  69. P.Name = "TrailPart"
  70. P.formFactor = "Custom"
  71. P.Size = Vector3.new(0.2,0.2,0.2)
  72. P.Locked = true
  73. P.Anchored = true
  74. P.CanCollide = false
  75. P.TopSurface = 0
  76. P.BottomSurface = 0
  77.  
  78. script.Name = "ParkourSkrip"
  79.  
  80. local hue = 0
  81.  
  82. function HSV(H,S,V)
  83. H = H % 360
  84. local C = V * S
  85. local H2 = H/60
  86. local X = C * (1 - math.abs((H2 %2) -1))
  87. local color = Color3.new(0,0,0)
  88. if H2 <= 0 then
  89. color = Color3.new(C,0,0)
  90. elseif 0 <= H2 and H2 <= 1 then
  91. color = Color3.new(C,X,0)
  92. elseif 1 <= H2 and H2 <= 2 then
  93. color = Color3.new(X,C,0)
  94. elseif 2 <= H2 and H2 <= 3 then
  95. color = Color3.new(0,C,X)
  96. elseif 3 <= H2 and H2 <= 4 then
  97. color = Color3.new(0,X,C)
  98. elseif 4 <= H2 and H2 <= 5 then
  99. color = Color3.new(X,0,C)
  100. elseif 5 <= H2 and H2 <= 6 then
  101. color = Color3.new(C,0,X)
  102. end
  103. local m = V - C
  104. return Color3.new(color.r + m, color.g + m, color.b + m)
  105. end
  106.  
  107. function GetWeld(weld)
  108. if weld:findFirstChild("XAngle") == nil then
  109. local a = Instance.new("NumberValue", weld)
  110. a.Name = "XAngle"
  111. end
  112. if weld:findFirstChild("YAngle") == nil then
  113. local a = Instance.new("NumberValue", weld)
  114. a.Name = "YAngle"
  115. end
  116. if weld:findFirstChild("ZAngle") == nil then
  117. local a = Instance.new("NumberValue", weld)
  118. a.Name = "ZAngle"
  119. end
  120. return weld.C0.p, Vector3.new(weld.XAngle.Value, weld.YAngle.Value, weld.ZAngle.Value)
  121. end
  122.  
  123. function SetWeld(weld, i, loops, origpos,origangle, nextpos,nextangle)
  124. if weld:findFirstChild("XAngle") == nil then
  125. local a = Instance.new("NumberValue", weld)
  126. a.Name = "XAngle"
  127. end
  128. if weld:findFirstChild("YAngle") == nil then
  129. local a = Instance.new("NumberValue", weld)
  130. a.Name = "YAngle"
  131. end
  132. if weld:findFirstChild("ZAngle") == nil then
  133. local a = Instance.new("NumberValue", weld)
  134. a.Name = "ZAngle"
  135. end
  136.  
  137. local tox,toy,toz = 0,0,0
  138. if origangle.x > nextangle.x then
  139. tox = -math.abs(origangle.x - nextangle.x) /loops*i
  140. else
  141. tox = math.abs(origangle.x - nextangle.x) /loops*i
  142. end
  143. if origangle.y > nextangle.y then
  144. toy = -math.abs(origangle.y - nextangle.y) /loops*i
  145. else
  146. toy = math.abs(origangle.y - nextangle.y) /loops*i
  147. end
  148. if origangle.z > nextangle.z then
  149. toz = -math.abs(origangle.z - nextangle.z) /loops*i
  150. else
  151. toz = math.abs(origangle.z - nextangle.z) /loops*i
  152. end
  153.  
  154. local tox2,toy2,toz2 = 0,0,0
  155. if origpos.x > nextpos.x then
  156. tox2 = -math.abs(origpos.x - nextpos.x) /loops*i
  157. else
  158. tox2 = math.abs(origpos.x - nextpos.x) /loops*i
  159. end
  160. if origpos.y > nextpos.y then
  161. toy2 = -math.abs(origpos.y - nextpos.y) /loops*i
  162. else
  163. toy2 = math.abs(origpos.y - nextpos.y) /loops*i
  164. end
  165. if origpos.z > nextpos.z then
  166. toz2 = -math.abs(origpos.z - nextpos.z) /loops*i
  167. else
  168. toz2 = math.abs(origpos.z - nextpos.z) /loops*i
  169. end
  170.  
  171. weld.XAngle.Value = origangle.x + tox
  172. weld.YAngle.Value = origangle.y + toy
  173. weld.ZAngle.Value = origangle.z + toz
  174. weld.C0 = CFrame.new(origpos.x + tox2,origpos.y + toy2,origpos.z + toz2) * CFrame.Angles(origangle.x + tox,origangle.y + toy,origangle.z + toz)
  175. end
  176.  
  177. function LoadTextures()
  178. local pls = game:service("ContentProvider")
  179. for i, v in pairs(loadids) do
  180. pls:Preload("http://www.roblox.com/asset/?id="..v)
  181. wait(0.04)
  182. end
  183. end
  184. LoadTextures()
  185.  
  186. function CreateGui()
  187. for i, v in pairs(player.PlayerGui:children()) do
  188. if v.className == "ScreenGui" and v.Name == "staminaGui" then
  189. v:remove()
  190. end
  191. end
  192. local g = Instance.new("ScreenGui", player.PlayerGui)
  193. g.Name = "staminaGui"
  194.  
  195. local c = Instance.new("Frame", g)
  196. c.Visible = false
  197. c.Size = UDim2.new(0,86,0,320)
  198. c.BackgroundTransparency = 1
  199. c.Position = UDim2.new(1,-96,0.5,-160)
  200. c.Name = "Container"
  201.  
  202. local t = Instance.new("TextLabel", c)
  203. t.Size = UDim2.new(0,0,-0.1,0)
  204. t.Position = UDim2.new(0.3,0,0.5,0)
  205. t.TextXAlignment = "Right"
  206. t.Font = "ArialBold"
  207. t.TextTransparency = 0.1
  208. t.TextColor3 = Color3.new(0,0.6,0.8)
  209. t.TextStrokeColor3 = Color3.new(0,0.2,0.8)
  210. t.TextStrokeTransparency = 0.3
  211. t.FontSize = 6
  212. t.BackgroundTransparency = 1
  213. local t2 = t:Clone()
  214. t2.Parent = c
  215. t2.Size = UDim2.new(0,0,0.1,0)
  216. local l = t:Clone()
  217. l.Parent = c
  218. l.Size = UDim2.new(0,0,0,0)
  219. l.Text = "-----"
  220.  
  221. local f1 = Instance.new("Frame", c)
  222. f1.Name = "Backing"
  223. f1.ClipsDescendants = true
  224. f1.Size = UDim2.new(1,0,0,0)
  225. f1.BackgroundColor3 = Color3.new(0.8,0,0)
  226. f1.BackgroundTransparency = 1
  227. local f1img = Instance.new("ImageLabel", f1)
  228. f1img.BackgroundTransparency = 1
  229. f1img.Image = "http://www.roblox.com/asset/?id=112474909"
  230. f1img.Size = UDim2.new(1,0,0,c.Size.Y.Offset)
  231.  
  232. local f2 = Instance.new("Frame", c)
  233. f2.Name = "Overlay"
  234. f2.ClipsDescendants = true
  235. f2.Size = UDim2.new(1,0,1,0)
  236. f2.BackgroundColor3 = Color3.new(0,0,0.8)
  237. f2.BackgroundTransparency = 1
  238. local f2img = Instance.new("ImageLabel", f2)
  239. f2img.BackgroundTransparency = 1
  240. f2img.Image = "http://www.roblox.com/asset/?id=112474911"
  241. f2img.Size = UDim2.new(1,0,0,c.Size.Y.Offset)
  242.  
  243. function Calculate()
  244. local ysize = c.Size.Y.Offset
  245. local per = (stamina/maxstamina) * c.Size.Y.Offset
  246. local rem = (-(stamina/maxstamina-1)) * c.Size.Y.Offset
  247. f1.Size = UDim2.new(1,0,0,rem)
  248. f2.Size = UDim2.new(1,0,0,per)
  249. f2.Position = UDim2.new(0,0,0,rem)
  250. f2img.Position = UDim2.new(0,0,0,-rem)
  251. t.Text = math.floor(stamina)
  252. t2.Text = maxstamina
  253. end
  254. Calculate()
  255.  
  256. wait(0.01)
  257. c.Visible = true
  258. end
  259. CreateGui()
  260.  
  261. player.CharacterAdded:connect(function()
  262. char = player.Character
  263. Torsoz = char:findFirstChild("Torso")
  264. RA = char:findFirstChild("Right Arm")
  265. LA = char:findFirstChild("Left Arm")
  266. RL = char:findFirstChild("Right Leg")
  267. LL = char:findFirstChild("Left Leg")
  268. H = char:findFirstChild("Head")
  269. Hu = char:findFirstChild("Humanoid")
  270. RS = Torsoz:findFirstChild("Right Shoulder")
  271. LS = Torsoz:findFirstChild("Left Shoulder")
  272. RH = Torsoz:findFirstChild("Right Hip")
  273. LH = Torsoz:findFirstChild("Left Hip")
  274. N = Torsoz:findFirstChild("Neck")
  275. stamina = maxstamina
  276. CreateGui()
  277. end)
  278.  
  279. function RAY(pos, dir, startpos, endpos, distleft, collidedlist)
  280. collidedlist = collidedlist or {char}
  281. startpos = startpos or pos
  282. distleft = distleft or dir.unit * dir.magnitude
  283. endpos = endpos or pos + distleft
  284. local ray = Ray.new(pos, distleft)
  285. local hitz,enz = workspace:FindPartOnRayWithIgnoreList(ray, collidedlist)
  286. --[[
  287. local p = P:Clone()
  288. p.Parent = char
  289. p.Size = Vector3.new(0.4,0.4,0.4)
  290. p.BrickColor = BrickColor.new("Lime green")
  291. p.CanCollide = false
  292. p.CFrame = CFrame.new(enz)
  293. p.Transparency = 0.3
  294. ]]
  295. if hitz ~= nil then
  296. if hitz.CanCollide == false then
  297. table.insert(collidedlist, hitz)
  298. local newpos = enz
  299. local newdistleft = distleft - (dir.unit * (pos - newpos).magnitude)
  300. if newdistleft ~= NV then
  301. return RAY(newpos-(dir*0.01), dir, startpos, endpos, newdistleft+(dir*0.01), collidedlist)
  302. end
  303. end
  304. end
  305.  
  306. return hitz, enz, ray
  307. end
  308.  
  309. function Sit()
  310. Standing = false
  311. local hitz,enz = RAY(Torsoz.Position, Vector3.new(0,-4.1,0))
  312. local tordir = Vector3.new(Torsoz.CFrame.lookVector.x,0,Torsoz.CFrame.lookVector.z)
  313. if (hitz ~= nil and hitz.CanCollide == true) then
  314. local cf = CFrame.new(enz+Vector3.new(0,1.28,0), enz+Vector3.new(0,1.28,0)+tordir) * CFrame.Angles(math.pi/6,0,0)
  315. local hitz2,enz2 = RAY(enz+Vector3.new(0,2.25,0), tordir*-2.2)
  316. Hu.PlatformStand = true
  317. Torsoz.CFrame = cf
  318. local bp = Instance.new("BodyPosition", Torsoz)
  319. bp.Name = "StaminaBodyObject"
  320. bp.maxForce = Vector3.new(1/0,1/0,1/0)
  321. bp.D = 100
  322. bp.position = cf.p
  323. local bg = Instance.new("BodyGyro", Torsoz)
  324. bg.Name = "StaminaBodyObject"
  325. bg.maxTorque = Vector3.new(1/0,1/0,1/0)
  326. bg.cframe = cf
  327. bg.D = 100
  328. SetWeld(Joint1,1,1, NV,NV, Vector3.new(0.34,-1,0.2), Vector3.new((math.pi/2)-(math.pi/6),0,math.pi/8))
  329. SetWeld(Joint2,1,1, NV,NV, Vector3.new(-0.34,-1,0.2), Vector3.new((math.pi/2)-(math.pi/6),0,-math.pi/8))
  330.  
  331. if hitz2 ~= nil and hitz2.CanCollide == true then
  332. Joint3.C0 = CFrame.new(0.9,0.4,-0.45) * CFrame.Angles(0,math.pi/2.13,0) * CFrame.Angles(math.pi/2.3,0,0)
  333. Joint4.C0 = CFrame.new(-0.9,0.4,-0.4) * CFrame.Angles(0,-math.pi/2.05,0) * CFrame.Angles(math.pi/2.3,0,0)
  334. Joint5.C0 = CFrame.new(0,1,0) * CFrame.Angles(-math.pi/8.8,0,0)
  335. else
  336. SetWeld(Joint3,1,1, NV,NV, Vector3.new(1.4,0.4,0.1), Vector3.new(-(math.pi/6)-(math.pi/10),0,math.pi/9))
  337. SetWeld(Joint4,1,1, NV,NV, Vector3.new(-1.4,0.4,0.1), Vector3.new(-(math.pi/6)-(math.pi/10),0,-math.pi/9))
  338. SetWeld(Joint5,1,1, NV,NV, Vector3.new(0,1,0), Vector3.new(-math.pi/12,0,0))
  339. end
  340.  
  341. Sitting = true
  342. Action = "Sitting"
  343. end
  344. end
  345.  
  346.  
  347. function Stand()
  348. Hu.PlatformStand = false
  349. if Sitting == true then
  350. local tordir = Torsoz.Position + (Torsoz.CFrame.lookVector*10000)
  351. local cf = CFrame.new(Torsoz.Position + Vector3.new(0,1.8,0), Vector3.new(tordir.x,Torsoz.Position.y,tordir.z))
  352. Torsoz.CFrame = cf
  353. end
  354. for i, v in pairs(Torsoz:children()) do
  355. if v.Name == "StaminaBodyObject" then
  356. v:remove()
  357. end
  358. end
  359. RH.Part0 = nil
  360. LH.Part0 = nil
  361. RS.Part0 = nil
  362. LS.Part0 = nil
  363. Joint1.Part0 = Torsoz
  364. Joint1.Part1 = RL
  365. Joint1.C0 = CFrame.new(0.5,-1,0)
  366. Joint1.C1 = CFrame.new(0,1,0)
  367. Joint2.Part0 = Torsoz
  368. Joint2.Part1 = LL
  369. Joint2.C0 = CFrame.new(-0.5,-1,0)
  370. Joint2.C1 = CFrame.new(0,1,0)
  371. Joint3.Part0 = Torsoz
  372. Joint3.Part1 = RA
  373. Joint3.C0 = CFrame.new(1.5,0.5,0)
  374. Joint3.C1 = CFrame.new(0,0.5,0)
  375. Joint4.Part0 = Torsoz
  376. Joint4.Part1 = LA
  377. Joint4.C0 = CFrame.new(-1.5,0.5,0)
  378. Joint4.C1 = CFrame.new(0,0.5,0)
  379. Joint5.Part0 = Torsoz
  380. Joint5.Part1 = H
  381. Joint5.C0 = CFrame.new(0,1,0)
  382. Joint5.C1 = CFrame.new(0,-0.5,0)
  383. Sitting = false
  384. Diving = false
  385. Standing = true
  386. Action = "Standing"
  387. end
  388.  
  389. --------------------------------------- Dive ----------------------------------
  390.  
  391. function Dive()
  392. stamina = stamina - 10
  393. flow.Value = flow.Value + 10
  394. if flow.Value > 100 then
  395. flow.Value = 100
  396. end
  397. Standing = false
  398. local dir = Vector3.new(Torsoz.CFrame.lookVector.x,0,Torsoz.CFrame.lookVector.z)
  399. GravPoint = 18
  400. DivingDir = dir
  401. local cf = CFrame.new(Torsoz.Position, dir+Vector3.new(0,Torsoz.Position.y,0))
  402. DivingCF = cf
  403. DivingDir = dir
  404. Hu.PlatformStand = true
  405. local bv = Instance.new("BodyVelocity", Torsoz)
  406. bv.Name = "StaminaBodyObject"
  407. bv.maxForce = Vector3.new(1/0,1/0,1/0)
  408. bv.velocity = Vector3.new(DivingDir.x*24,GravPoint,DivingDir.z*24)
  409. DivingBV = bv
  410. local bg = Instance.new("BodyGyro", Torsoz)
  411. bg.Name = "StaminaBodyObject"
  412. bg.maxTorque = Vector3.new(1/0,1/0,1/0)
  413. bg.cframe = CFrame.new(Torsoz.Position, Torsoz.Position+bv.velocity) * CFrame.Angles(-math.pi/2,0,0)
  414. bg.D = 100
  415. DivingBG = bg
  416.  
  417. local joint = Joint3
  418. joint.C1 = CFrame.new(0,0.5,0)
  419. local joint2 = Joint4
  420. joint2.C1 = CFrame.new(0,0.5,0)
  421. local joint3 = Joint1
  422. joint3.C1 = CFrame.new(0,1,0)
  423. local joint4 = Joint2
  424. joint4.C1 = CFrame.new(0,1,0)
  425.  
  426. local joint5 = Joint5
  427.  
  428. Diving = true
  429. Action = "Diving"
  430.  
  431. for i = 1, 8 do
  432. SetWeld(joint,i,8, Vector3.new(1.5,0.5,0), NV, Vector3.new(1.45,0.5,0.1), Vector3.new(-0.2,-math.pi/9,math.pi/13))
  433. SetWeld(joint2,i,8, Vector3.new(-1.5,0.5,0), NV, Vector3.new(-1.45,0.5,0.1), Vector3.new(-0.2,math.pi/9,-math.pi/13))
  434. SetWeld(joint3,i,8, Vector3.new(0.5,-1,0), NV, Vector3.new(0.5,-1,0.03), Vector3.new(-0.2,-math.pi/10,math.pi/14))
  435. SetWeld(joint4,i,8, Vector3.new(-0.5,-1,0), NV, Vector3.new(-0.5,-1,0.03), Vector3.new(-0.2,math.pi/10,-math.pi/14))
  436. SetWeld(joint5,i,8, Vector3.new(0,1,0), NV, Vector3.new(0,1,0), Vector3.new(0.45,0,0))
  437. wait(0.025)
  438. end
  439.  
  440. local counter = 0
  441. while Diving == true do
  442. counter = counter + 1
  443. bg.Parent = Torsoz
  444. local hitz, enz = RAY(Torsoz.Position, bv.velocity.unit*4.6)
  445. if hitz ~= nil and hitz.CanCollide == true then
  446. local hitz2, enz2 = RAY(Torsoz.Position, Vector3.new(0,-4,0))
  447. if hitz2 ~= nil then
  448. Diving = "Rolling"
  449. Action = "DiveRolling"
  450. else
  451. Torsoz.CFrame = Torsoz.CFrame * CFrame.new(0,-0.3,0)
  452. Torsoz.Velocity = NV
  453. flow.Value = 0
  454. break
  455. end
  456. end
  457. if counter > 190 then
  458. break
  459. end
  460. wait(0.02)
  461. end
  462.  
  463. bv.velocity = (dir*20) + Vector3.new(0,-0.5,0)
  464.  
  465. local bgcf = bg.cframe
  466. local haslanded = false
  467. local count = 0
  468.  
  469. while haslanded == false do
  470. bg.cframe = bgcf * CFrame.Angles(-0.3*count,0,0)
  471. local hitz, enz = RAY(Torsoz.Position, ((Torsoz.CFrame*CFrame.new(0,-1,0)).p - Torsoz.CFrame.p).unit*1.6)
  472. if hitz ~= nil and hitz.CanCollide == true then
  473. haslanded = true
  474. end
  475. local hitz2, enz2 = RAY(Torsoz.Position, Vector3.new(0,-3.8,0))
  476. if hitz2 == nil then
  477. Torsoz.Velocity = NV
  478. break
  479. elseif haslanded == true then
  480. local bp = Instance.new("BodyPosition", Torsoz)
  481. bp.Name = "StaminaJumpFix"
  482. bp.maxForce = Vector3.new(0,1/0,0)
  483. bp.P = 7000
  484. bp.position = enz2 + Vector3.new(0,2.8,0)
  485. game:service("Debris"):AddItem(bp, 0.3)
  486. else
  487. bv.velocity = (dir*20) + Vector3.new(0,-(Torsoz.Position - enz2).magnitude*3,0)
  488.  
  489. end
  490. count = count + 1
  491. if count <= 6 then
  492. local i = count
  493. local j1,j1a = GetWeld(joint)
  494. local j2,j2a = GetWeld(joint2)
  495. local j3,j3a = GetWeld(joint3)
  496. local j4,j4a = GetWeld(joint4)
  497. local j5,j5a = GetWeld(joint5)
  498. SetWeld(joint,i,6, j1,j1a, Vector3.new(1.35,0.5,-0.2), Vector3.new(math.pi/2.6,0,-math.pi/5.8))
  499. SetWeld(joint2,i,6, j2,j2a, Vector3.new(-1.35,0.5,-0.2), Vector3.new(math.pi/2.6,0,math.pi/5.8))
  500. SetWeld(joint3,i,6, j3,j3a, Vector3.new(0.51,0.4,-0.6), Vector3.new(-0.1,0,0.05))
  501. SetWeld(joint4,i,6, j4,j4a, Vector3.new(-0.51,0.4,-0.6), Vector3.new(-0.1,0,-0.05))
  502. SetWeld(joint5,i,6, j5,j5a, Vector3.new(0,1,0), Vector3.new(-0.4,0,0))
  503. elseif count >= 50 then
  504. break
  505. end
  506. wait(0.02)
  507. end
  508.  
  509. Torsoz.Velocity = NV
  510.  
  511. Stand()
  512. DivingCooldown = 9
  513. end
  514.  
  515. function FindSurface(part, position)
  516. local obj = part.CFrame:pointToObjectSpace(position)
  517. local siz = part.Size/2
  518. for i,v in pairs(Enum.NormalId:GetEnumItems()) do
  519. local vec = Vector3.FromNormalId(v)
  520. local wvec = part.CFrame:vectorToWorldSpace(vec)
  521. local vz = (obj)/(siz*vec)
  522. if (math.abs(vz.X-1) < 0.01 or math.abs(vz.Y-1) < 0.01 or math.abs(vz.Z-1) < 0.01) then
  523. return wvec,vec
  524. end
  525. end
  526. if part.className == "WedgePart" then
  527. return part.CFrame:vectorToWorldSpace(Vector3.new(0,0.707,-0.707)), Vector3.new(0,0.707,-0.707)
  528. end
  529. end
  530.  
  531. function HWallRun(part, pos, side)
  532. if (part.className == "Part" and part.Shape == Enum.PartType.Block) or part.className ~= "Part" then
  533. flow.Value = flow.Value + 9
  534. Standing = false
  535. HWallRunning = true
  536. Action = "HWallRunning"
  537. GravPoint = 10
  538. HWRLastPart = part
  539. local dir, dirc = FindSurface(part, pos)
  540. towall = -dir
  541. dir = (CFrame.new(NV, dir) * CFrame.Angles(0,side,0)).lookVector
  542.  
  543. local bv = Instance.new("BodyVelocity", Torsoz)
  544. bv.Name = "StaminaBodyObject"
  545. bv.maxForce = Vector3.new(1/0,1/0,1/0)
  546. bv.P = 9000
  547. bv.velocity = (dir*(sprint-0.5)) + Vector3.new(0,GravPoint,0)
  548. local bg = Instance.new("BodyGyro", Torsoz)
  549. bg.Name = "StaminaBodyObject"
  550. bg.maxTorque = Vector3.new(1/0,1/0,1/0)
  551. bg.cframe = CFrame.new(Torsoz.Position+(towall*-2), Torsoz.Position) * CFrame.Angles(0,-side,-side/4.2)
  552. bg.D = 100
  553.  
  554. local sid = Instance.new("Snap")
  555.  
  556. local joint1 = Joint3
  557. if side == -math.pi/2 then
  558. SetWeld(joint1,1,1, NV,NV, Vector3.new(1.5,0.5,0), Vector3.new(math.pi/1.3,0.1,math.pi/2.5))
  559. else
  560. sid = joint1
  561. SetWeld(joint1,1,1, NV,NV, Vector3.new(1.4,0.6,0), Vector3.new(-math.pi/12,0,math.pi/7))
  562. end
  563. local j1c0 = joint1.C0
  564.  
  565. local joint2 = Joint4
  566. if side == math.pi/2 then
  567. SetWeld(joint2,1,1, NV,NV, Vector3.new(-1.5,0.5,0), Vector3.new(math.pi/1.3,-0.1,-math.pi/2.5))
  568. else
  569. sid = joint2
  570. SetWeld(joint2,1,1, NV,NV, Vector3.new(-1.4,0.6,0), Vector3.new(-math.pi/12,0,-math.pi/7))
  571. end
  572. local j2c0 = joint2.C0
  573.  
  574. local joint3 = Joint1
  575. joint3.C1 = CFrame.new(0,1,0)
  576. if side == -math.pi/2 then
  577. SetWeld(joint3,1,1, NV,NV, Vector3.new(0.5,-0.38,-0.3), Vector3.new(0,math.pi/2,0.14))
  578. else
  579. SetWeld(joint3,1,1, NV,NV, Vector3.new(0.5,-0.8,-0.2), Vector3.new(0,math.pi/2,0.2))
  580. end
  581.  
  582. local joint4 = Joint2
  583. joint4.C1 = CFrame.new(0,1,0)
  584. if side == -math.pi/2 then
  585. SetWeld(joint4,1,1, NV,NV, Vector3.new(-0.5,-0.8,-0.2), Vector3.new(0,0,0.2))
  586. else
  587. SetWeld(joint4,1,1, NV,NV, Vector3.new(-0.5,-0.38,-0.3), Vector3.new(0,0,0.14))
  588. end
  589.  
  590. local joint5 = Joint5
  591. SetWeld(joint5,1,1,NV,NV,Vector3.new(0,0.9,0),Vector3.new(0,0,side/7))
  592.  
  593. Torsoz.CFrame = CFrame.new(pos+(towall*-2), pos) * CFrame.Angles(0,-side,-side/2.2)
  594. bg.cframe = CFrame.new(pos+(towall*-2), pos) * CFrame.Angles(0,-side,-side/2.2)
  595.  
  596. local aniangle = 0
  597. local aniplus = true
  598. local aniangle2 = 0
  599. local aniplus2 = true
  600.  
  601. local prevpart = part
  602. HWRLastPart = part
  603. while HWallRunning == true do
  604.  
  605. if aniangle > math.pi then
  606. aniplus = false
  607. elseif aniangle < -math.pi then
  608. aniplus = true
  609. end
  610. if aniplus == true then
  611. aniangle = aniangle + 0.95
  612. elseif aniplus == false then
  613. aniangle = aniangle - 0.95
  614. end
  615.  
  616. if aniangle2 > math.pi then
  617. aniplus2 = false
  618. elseif aniangle2 < -math.pi then
  619. aniplus2 = true
  620. end
  621. if aniplus2 == true then
  622. aniangle2 = aniangle2 + 0.23
  623. elseif aniplus2 == false then
  624. aniangle2 = aniangle2 - 0.23
  625. end
  626.  
  627. Hu.PlatformStand = true
  628. local hitz, enz = RAY(Torsoz.Position, Vector3.new(0,-3,0))
  629. local hitz2, enz2 = RAY(Torsoz.Position, towall*3.4)
  630.  
  631. --- if player ends wall run on ground
  632. if hitz ~= nil and hitz.CanCollide == true then
  633. bg.cframe = CFrame.new(enz2+(towall*-2), enz2) * CFrame.Angles(0,-side,0)
  634. local offset = (bg.cframe.p.y+enz2.y) - bg.cframe.p.y
  635. Torsoz.CFrame = CFrame.new(Vector3.new(bg.cframe.p.x,offset,bg.cframe.p.z), enz2) * CFrame.Angles(0,-side,0)
  636. Torsoz.Velocity = NV
  637. break
  638. end
  639.  
  640. ---- if new wall found --------
  641. if hitz2 ~= nil and hitz2.CanCollide == true then
  642. if hitz2 ~= prevpart then
  643. local direct = CFrame.new(Torsoz.Position, Torsoz.Position+dir) * CFrame.Angles(0,side,0)
  644. local hitz3, enz3 = RAY(Torsoz.Position, (direct * CFrame.Angles(0,-side/2.3,0)).lookVector*4)
  645. if hitz3 ~= nil then
  646. Torsoz.CFrame = CFrame.new(enz2+(towall*-2), enz2) * CFrame.Angles(0,-side*1.1,-side/2.2)
  647. bg.cframe = CFrame.new(enz2+(towall*-2), enz2) * CFrame.Angles(0,-side*1.1,-side/2.2)
  648. dir, dirc = FindSurface(hitz2, enz2)
  649. towall = -dir
  650. dir = (CFrame.new(NV, dir) * CFrame.Angles(0,side,0)).lookVector
  651. prevpart = hitz2
  652. HWRLastPart = hitz2
  653. else
  654. ---- if player fails to find new wall to run on
  655. Torsoz.CFrame = CFrame.new(Torsoz.Position, Torsoz.Position+dir)
  656. bg.cframe = CFrame.new(Torsoz.Position, Torsoz.Position+dir)
  657. Torsoz.Velocity = NV
  658. HWRCooldown = 5
  659. break
  660. end
  661. end
  662. --- continue to wall run
  663. Torsoz.CFrame = CFrame.new(enz2+(towall*-2), enz2) * CFrame.Angles(0,-side,-side/2.2)
  664. bg.cframe = CFrame.new(enz2+(towall*-2), enz2) * CFrame.Angles(0,-side,-side/2.2)
  665. else
  666. ---- if player ends wall run at end of wall
  667. Torsoz.CFrame = CFrame.new(Torsoz.Position, Torsoz.Position+dir)
  668. bg.cframe = CFrame.new(Torsoz.Position, Torsoz.Position+dir)
  669. Torsoz.Velocity = NV
  670. HWRCooldown = 5
  671. break
  672. end
  673.  
  674. local hitz3, enz3 = RAY(Torsoz.Position, Torsoz.CFrame.lookVector*2)
  675. if hitz3 ~= nil and hitz3.CanCollide == true then
  676. Torsoz.CFrame = CFrame.new(Torsoz.Position, Torsoz.Position+dir)
  677. bg.cframe = CFrame.new(Torsoz.Position, Torsoz.Position+dir)
  678. Torsoz.Velocity = NV
  679. HWRCooldown = 5
  680. break
  681. end
  682.  
  683. bv.Parent = Torsoz
  684. bv.velocity = (dir*(sprint-0.5)) + Vector3.new(0,GravPoint,0)
  685. bg.cframe = bg.cframe * CFrame.Angles(aniangle/80,aniangle/80,0)
  686. Torsoz.CFrame = Torsoz.CFrame * CFrame.Angles(aniangle/80,aniangle/80,0)
  687. local j3,j3a = GetWeld(joint3)
  688. local j4,j4a = GetWeld(joint4)
  689. SetWeld(joint3,1,1, j3,j3a, j3,Vector3.new(-0.2+(aniangle/4),0,0))
  690. SetWeld(joint4,1,1, j4,j4a, j4,Vector3.new(-0.2+(-aniangle/4),0,0))
  691. if side == math.pi/2 then
  692. local j1,j1a = GetWeld(joint1)
  693. SetWeld(joint1,1,1, j1,j1a, j1, Vector3.new(0,0,0.8+(aniangle2/14)))
  694. else
  695. local j2,j2a = GetWeld(joint2)
  696. SetWeld(joint2,1,1, j2,j2a, j2, Vector3.new(0,0,-0.8-(aniangle2/14)))
  697. end
  698.  
  699. wait(0.025)
  700. if GravPoint < -100 then
  701. bg.cframe = CFrame.new(enz2+(towall*-2), enz2) * CFrame.Angles(0,-side,0)
  702. local offset = math.abs((bg.cframe.p.y+enz2.y) - bg.cframe.p.y)
  703. Torsoz.CFrame = CFrame.new(Vector3.new(bg.cframe.p.x,offset,bg.cframe.p.z), enz2) * CFrame.Angles(0,-side,0)
  704. break
  705. end
  706.  
  707. end
  708.  
  709. if HWallRunning == "Jumping" then
  710. HWRCooldown = 6
  711. joint1.C1 = CFrame.new(0,0.5,0)
  712.  
  713. joint2.C1 = CFrame.new(0,0.5,0)
  714. if side == -math.pi/2 then
  715. joint2.C0 = CFrame.new(-1.35,0.5,0) * CFrame.Angles(0,side/2.4,-math.pi/3)
  716. else
  717. joint2.C0 = CFrame.new(-1.35,0.5,0) * CFrame.Angles(0,side/2.4,-math.pi/4)
  718. end
  719.  
  720. joint3.C1 = CFrame.new(0,1,0)
  721. if side == -math.pi/2 then
  722. joint3.C0 = CFrame.new(0.5,-0.8,0) * CFrame.Angles(0,math.pi+(side/2.4),-math.pi/4)
  723. else
  724. joint3.C0 = CFrame.new(0.5,-0.8,0) * CFrame.Angles(0,(side/2.4),math.pi/4)
  725. end
  726. joint4.MaxVelocity = 10
  727. joint4.DesiredAngle = 0
  728. joint4.C1 = CFrame.new(0,1,0)
  729. if side == -math.pi/2 then
  730. joint4.C0 = CFrame.new(-0.5,-0.8,0) * CFrame.Angles(0,math.pi+(side/2.4),math.pi/4)
  731. else
  732. joint4.C0 = CFrame.new(-0.5,-0.8,0) * CFrame.Angles(0,(side/2.4),-math.pi/4)
  733. end
  734.  
  735. local joint5 = Joint5
  736. joint5.C1 = CFrame.new(0,-0.5,0) * CFrame.Angles(0,side/2.4,0)
  737. joint5.C0 = CFrame.new(0,1,0)
  738.  
  739. local j1,j1a = GetWeld(joint1)
  740. local j2,j2a = GetWeld(joint2)
  741. local j3,j3a = GetWeld(joint3)
  742. local j4,j4a = GetWeld(joint4)
  743. local j5,j5a = GetWeld(joint5)
  744.  
  745. GravPoint = 26
  746. local collidecount = 0
  747. local bgangle = side/2
  748. local count = 1
  749. local dir2 = (CFrame.new(NV, dir) * CFrame.Angles(0,-side/2.4,0)).lookVector
  750. HWRDir = dir2
  751. bv.velocity = (dir2*(sprint+5)) + Vector3.new(0,GravPoint,0)
  752. while HWallRunning == "Jumping" do
  753. local hitz, enz = RAY(Torsoz.Position, Vector3.new(0,-4,0))
  754. local hitz2, enz2 = RAY(Torsoz.Position, dir2*1.4)
  755. if hitz ~= nil and hitz.CanCollide == true then
  756. local offset = math.abs(enz.y - Torsoz.CFrame.p.y)
  757. Torsoz.CFrame = CFrame.new(enz+Vector3.new(0,2.9,0), enz+Vector3.new(0,2.9,0)+dir2)
  758. Torsoz.Velocity = NV
  759. break
  760. end
  761.  
  762. if hitz2 ~= nil and hitz2.CanCollide == true then
  763. collidecount = collidecount + 1
  764. if collidecount == 4 then
  765. Torsoz.CFrame = CFrame.new(Torsoz.Position, Torsoz.Position+dir2) * CFrame.new(0,0,0.4)
  766. Torsoz.Velocity = Vector3.new(0,Torsoz.Velocity.y,0)
  767. HWRCooldown = 5
  768. VWRCooldown = 5
  769. wait(0.02)
  770. break
  771. end
  772. end
  773.  
  774. if side/2 > 0 then
  775. if bgangle > 0.2 then
  776. bgangle = bgangle - 0.055
  777. end
  778. else
  779. if bgangle < -0.2 then
  780. bgangle = bgangle + 0.055
  781. end
  782. end
  783.  
  784. if count <= 5 then
  785. if side == -math.pi/2 then
  786. SetWeld(joint1,count,5, j1,j1a, Vector3.new(1.35,0.5,0), Vector3.new(0,side/2.4,math.pi/4))
  787. SetWeld(joint2,count,5, j2,j2a, Vector3.new(-1.35,0.5,0), Vector3.new(0,side/2.4,-math.pi/3))
  788. SetWeld(joint3,count,5, j3,j3a, Vector3.new(0.5,-0.8,0), Vector3.new(0,-side/1.7,0))
  789. joint3.C0 = joint3.C0 * CFrame.Angles((-math.pi/4)/5*count,0,0)
  790. SetWeld(joint4,count,5, j4,j4a, Vector3.new(-0.5,-0.8,0), Vector3.new(0,-side/1.7,0))
  791. joint4.C0 = joint4.C0 * CFrame.Angles((math.pi/4)/5*count,0,0)
  792. else
  793. SetWeld(joint1,count,5, j1,j1a, Vector3.new(1.35,0.5,0), Vector3.new(0,side/2.4,math.pi/3))
  794. SetWeld(joint2,count,5, j2,j2a, Vector3.new(-1.35,0.5,0), Vector3.new(0,side/2.4,-math.pi/4))
  795. SetWeld(joint3,count,5, j3,j3a, Vector3.new(0.5,-0.8,0), Vector3.new(0,-side/1.7,0))
  796. joint3.C0 = joint3.C0 * CFrame.Angles((math.pi/4)/5*count,0,0)
  797. SetWeld(joint4,count,5, j4,j4a, Vector3.new(-0.5,-0.8,0), Vector3.new(0,-side/1.7,0))
  798. joint4.C0 = joint4.C0 * CFrame.Angles((-math.pi/4)/5*count,0,0)
  799. end
  800.  
  801. count = count + 1
  802. end
  803.  
  804. bg.Parent = Torsoz
  805. bg.cframe = CFrame.new(NV, dir) * CFrame.Angles(0,side/15,-bgangle)
  806. bv.velocity = (dir2*(sprint+5)) + Vector3.new(0,GravPoint,0)
  807. if collidecount ~= 0 then
  808. bv.velocity = Vector3.new(0,bv.velocity.y,0)
  809. end
  810. if GravPoint < -120 then
  811. break
  812. end
  813. wait(0.025)
  814. end
  815. end
  816.  
  817. Hu.PlatformStand = false
  818. bv:remove()
  819.  
  820. HWRGravDrop = false
  821. Stand()
  822. HWallRunning = false
  823. end
  824. end
  825.  
  826. function VWR(part, pos)
  827. if (part.className == "Part" and part.Shape == Enum.PartType.Block) or part.className ~= "Part" then
  828. print("VWR Activated")
  829. flow.Value = flow.Value + 9
  830. Standing = false
  831. VWallRunning = true
  832. Action = "VWallRunning"
  833. GravPoint = 0
  834. local percent = 1
  835. VWRLastPart = part
  836. local dir, dirc = FindSurface(part, pos)
  837. towall = -dir
  838. dir = (CFrame.new(NV, -dir) * CFrame.Angles(math.pi/2,0,0)).lookVector
  839. --[[
  840. local p = P:Clone()
  841. p.Parent = char
  842. p.Size = Vector3.new(2,2,2)
  843. p.BrickColor = BrickColor.new("Lime green")
  844. p.CanCollide = false
  845. p.CFrame = part.CFrame * CFrame.new(dirc*5)
  846. p.Transparency = 0.3
  847. ]]
  848. local bv = Instance.new("BodyVelocity", Torsoz)
  849. bv.Name = "StaminaBodyObject"
  850. bv.maxForce = Vector3.new(1/0,1/0,1/0)
  851. bv.P = 9000
  852. bv.velocity = (dir*(sprint-1))*percent
  853.  
  854. local bg = Instance.new("BodyGyro", Torsoz)
  855. bg.Name = "StaminaBodyObject"
  856. bg.maxTorque = Vector3.new(1/0,1/0,1/0)
  857. bg.D = 100
  858. local posi = pos + (-towall*1.8)
  859. bg.cframe = CFrame.new(posi, posi+towall) * CFrame.Angles((math.pi/5),0,0)
  860. Torsoz.CFrame = CFrame.new(posi, posi+towall) * CFrame.Angles((math.pi/5),0,0)
  861.  
  862. local joint1 = Joint3
  863. SetWeld(joint1,1,1, NV,NV, Vector3.new(1.4,0.45,-0.1), Vector3.new(-math.pi/3.2,0,math.pi/8))
  864.  
  865. local joint2 = Joint4
  866. SetWeld(joint2,1,1, NV,NV, Vector3.new(-1.4,0.45,-0.1), Vector3.new(-math.pi/3.2,0,-math.pi/8))
  867.  
  868. local joint3 = Joint1
  869. SetWeld(joint3,1,1, NV,NV, Vector3.new(0.48,-0.6,-0.1), Vector3.new(0,math.pi/2,0))
  870. joint3.C1 = CFrame.new(0,0.7,0.2) * CFrame.Angles(0,math.pi/2,0)
  871.  
  872. local joint4 = Joint2
  873. SetWeld(joint4,1,1, NV,NV, Vector3.new(-0.48,-0.6,-0.1), Vector3.new(0,math.pi/2,0))
  874. joint4.C1 = CFrame.new(0,0.7,0.2) * CFrame.Angles(0,math.pi/2,0)
  875.  
  876. local joint5 = Joint5
  877. SetWeld(joint5,1,1, NV,NV, Vector3.new(0,1,0), Vector3.new(math.pi/20,0,0))
  878.  
  879. local aniangle = 0
  880. local aniplus = true
  881.  
  882. while VWallRunning == true do
  883. local hitz, enz = RAY(Torsoz.Position, towall*2.1)
  884. local hitz2, enz2 = RAY(Torsoz.Position, (CFrame.new(NV,towall)*CFrame.Angles(math.pi/2,0,0)).lookVector*2.4)
  885.  
  886. if aniangle > math.pi then
  887. aniplus = false
  888. elseif aniangle < -math.pi then
  889. aniplus = true
  890. end
  891. if aniplus == true then
  892. aniangle = aniangle + (1.3*(percent+0.2))
  893. elseif aniplus == false then
  894. aniangle = aniangle - (1.3*(percent+0.2))
  895. end
  896.  
  897. bv.velocity = (dir*(sprint-1))*percent
  898. if VWRLeft == true then
  899. bv.velocity = bv.velocity + ((CFrame.new(NV, towall) * CFrame.Angles(0,math.pi/2,0)).lookVector * (11*percent+5))
  900. end
  901. if VWRRight == true then
  902. bv.velocity = bv.velocity - ((CFrame.new(NV, towall) * CFrame.Angles(0,math.pi/2,0)).lookVector * (11*percent+5))
  903. end
  904.  
  905. bg.cframe = CFrame.new(posi, posi+towall) * CFrame.Angles((math.pi/5),0,0) * CFrame.Angles(0,aniangle/60,0)
  906.  
  907. SetWeld(joint1,1,1, NV,NV, Vector3.new(1.4,0.45,-0.1), Vector3.new(-math.pi/3.2,aniangle/52,(math.pi/8)+(aniangle/30)))
  908. SetWeld(joint2,1,1, NV,NV, Vector3.new(-1.4,0.45,-0.1), Vector3.new(-math.pi/3.2,aniangle/52,(-math.pi/8)+(-aniangle/30)))
  909. SetWeld(joint3,1,1, NV,NV, Vector3.new(0.51,-0.75,-(aniangle/30)), Vector3.new(0,math.pi/2,(aniangle/8)-0.3))
  910. SetWeld(joint4,1,1, NV,NV, Vector3.new(-0.51,-0.75,(aniangle/30)), Vector3.new(0,math.pi/2,(-aniangle/8)-0.3))
  911.  
  912. if hitz == nil then
  913. local lv = Torsoz.Position + (Torsoz.CFrame.lookVector*100)
  914. Torsoz.CFrame = CFrame.new(Torsoz.Position, Vector3.new(lv.x,Torsoz.Position.y,lv.z))
  915. break
  916. end
  917.  
  918. if hitz2 ~= nil then
  919. percent = 0
  920. VWallRunning = "Falling"
  921. Action = "VWRFalling"
  922. GravPoint = -7
  923. break
  924. end
  925.  
  926. wait(0.02)
  927. percent = percent - 0.028
  928. if percent <= 0.15 then
  929. VWallRunning = "Falling"
  930. Action = "VWRFalling"
  931. end
  932. end
  933.  
  934. -------------------------- Falling from VWR ------------------------------
  935. if VWallRunning == "Falling" then
  936. GravPoint = GravPoint - 1
  937. local dirpos = (-towall *5) + Vector3.new(0,GravPoint,0)
  938. bv.velocity = CFrame.new(NV, dirpos).lookVector * dirpos.magnitude
  939.  
  940. local j1,j1a = GetWeld(joint1)
  941. local j2,j2a = GetWeld(joint2)
  942. local j3,j3a = GetWeld(joint3)
  943. local j4,j4a = GetWeld(joint4)
  944. local j5,j5a = GetWeld(joint5)
  945.  
  946. local counter = 0
  947. while VWallRunning == "Falling" do
  948. counter = counter + 1
  949. local hitz, enz = RAY(H.Position, Vector3.new(0,-2.4,0))
  950.  
  951. dirpos = (-towall *5) + Vector3.new(0,GravPoint,0)
  952. bv.velocity = CFrame.new(NV, dirpos).lookVector * dirpos.magnitude
  953. if VWRLeft == true then
  954. bv.velocity = bv.velocity + ((CFrame.new(NV, towall) * CFrame.Angles(0,math.pi/2,0)).lookVector * 9)
  955. end
  956. if VWRRight == true then
  957. bv.velocity = bv.velocity - ((CFrame.new(NV, towall) * CFrame.Angles(0,math.pi/2,0)).lookVector * 9)
  958. end
  959. bg.cframe = CFrame.new(NV, (-towall*30) + Vector3.new(0,GravPoint,0)) * CFrame.Angles(-math.pi/2.55,math.pi,0)
  960.  
  961. if counter <= 35 then
  962. SetWeld(joint1,counter,35, j1,j1a, Vector3.new(1.4,0.45,-0.1), Vector3.new(math.pi/9,0,math.pi/9))
  963. SetWeld(joint2,counter,35, j2,j2a, Vector3.new(-1.4,0.45,-0.1), Vector3.new(math.pi/9,0,-math.pi/9))
  964. SetWeld(joint3,counter,35, j3,j3a, Vector3.new(0.5,-0.75,0), Vector3.new(0,math.pi/2,math.pi/9))
  965. joint3.C1 = CFrame.new(0,0.7 + (0.3/35*counter),0.2 - (0.2/35*counter)) * CFrame.Angles(0,math.pi/2,0)
  966. SetWeld(joint4,counter,35, j4,j4a, Vector3.new(-0.5,-0.75,0), Vector3.new(0,math.pi/2,math.pi/9))
  967. joint4.C1 = CFrame.new(0,0.7 + (0.3/35*counter),0.2 - (0.2/35*counter)) * CFrame.Angles(0,math.pi/2,0)
  968. SetWeld(joint5,counter,35, j5,j5a, Vector3.new(0,1,0), Vector3.new(-math.pi/6,0,0))
  969. end
  970.  
  971. if hitz ~= nil then
  972. bv:remove()
  973. Torsoz.CFrame = CFrame.new(enz+Vector3.new(0,2,0), (enz+Vector3.new(0,2,0)) + ((-towall*25) + Vector3.new(0,GravPoint,0))) * CFrame.Angles(-math.pi/2.55,math.pi,0)
  974. Torsoz.Velocity = NV
  975. Torsoz.RotVelocity = NV
  976. local bp = Instance.new("BodyPosition", Torsoz)
  977. bp.maxForce = Vector3.new(1/0,1/0,1/0)
  978. bp.position = Torsoz.CFrame.p
  979. game:service("Debris"):AddItem(bp, 0.16)
  980. flow.Value = 0
  981. break
  982. end
  983.  
  984. if GravPoint > - 180 then
  985. GravPoint = GravPoint - 1.9
  986. end
  987. if counter > 200 then
  988. break
  989. end
  990. wait(0.02)
  991. end
  992.  
  993. local bp = Instance.new("BodyPosition")
  994.  
  995. local counter2 = counter
  996. local bgangleplus = 0
  997.  
  998. local j1,j1a = GetWeld(joint1)
  999. local j2,j2a = GetWeld(joint2)
  1000. local j3,j3a = GetWeld(joint3)
  1001. local j4,j4a = GetWeld(joint4)
  1002. local j5,j5a = GetWeld(joint5)
  1003.  
  1004. local landingpos
  1005.  
  1006. while VWallRunning == "BackflipFromFall" do
  1007. counter2 = counter2 + 1
  1008. local hitz, enz = RAY(H.Position+Vector3.new(0,2,0), Vector3.new(0,-4.4,0))
  1009.  
  1010. if counter2 - counter < 13 then
  1011. bgangleplus = bgangleplus - ((math.pi*1.1)/13)
  1012. end
  1013. if counter2 - counter <= 13 then
  1014. SetWeld(joint1,counter2-counter,13, j1,j1a, Vector3.new(1.4,0.5,0.1), Vector3.new(math.pi/2,0.1,math.pi/2))
  1015. SetWeld(joint2,counter2-counter,13, j2,j2a, Vector3.new(-1.4,0.5,0.1), Vector3.new(math.pi/2,-0.1,-math.pi/2))
  1016. SetWeld(joint3,counter2-counter,13, j3,j3a, Vector3.new(0.52,-0.3,-0.65), Vector3.new(0,math.pi/2,0))
  1017. SetWeld(joint4,counter2-counter,13, j4,j4a, Vector3.new(-0.51,-0.9,-0.05), Vector3.new(0,math.pi/2,0))
  1018. SetWeld(joint5,counter2-counter,13, j5,j5a, Vector3.new(0,0.9,0), Vector3.new(-math.pi/7,0,0))
  1019. end
  1020.  
  1021. dirpos = (-towall *5) + Vector3.new(0,GravPoint,0)
  1022. --bv.velocity = Vector3.new(0,-2,0)
  1023. bv.velocity = CFrame.new(NV, dirpos).lookVector * dirpos.magnitude
  1024. if VWRLeft == true then
  1025. bv.velocity = bv.velocity + ((CFrame.new(NV, towall) * CFrame.Angles(0,math.pi/2,0)).lookVector * 9)
  1026. end
  1027. if VWRRight == true then
  1028. bv.velocity = bv.velocity - ((CFrame.new(NV, towall) * CFrame.Angles(0,math.pi/2,0)).lookVector * 9)
  1029. end
  1030. bg.cframe = CFrame.new(NV, (-towall*30) + Vector3.new(0,GravPoint,0)) * CFrame.Angles((-math.pi/2.4) + bgangleplus,math.pi,0)
  1031.  
  1032. if hitz ~= nil then
  1033. bv:remove()
  1034. landingpos = enz - (towall*1.3)
  1035. if counter2 - counter > 8 then
  1036. bp = Instance.new("BodyPosition", Torsoz)
  1037. bp.maxForce = Vector3.new(1/0,1/0,1/0)
  1038. bp.position = enz+Vector3.new(0,2.4,0) + (-towall*1)
  1039. VWallRunning = "LandingFall"
  1040. else
  1041. Torsoz.CFrame = bg.cframe + (enz+Vector3.new(0,2.3,0))
  1042. Torsoz.Velocity = NV
  1043. Torsoz.RotVelocity = NV
  1044. local bp = Instance.new("BodyPosition", Torsoz)
  1045. bp.maxForce = Vector3.new(1/0,1/0,1/0)
  1046. bp.position = Torsoz.CFrame.p
  1047. game:service("Debris"):AddItem(bp, 0.14)
  1048. flow.Value = 0
  1049. end
  1050. break
  1051. end
  1052.  
  1053. if GravPoint > - 180 then
  1054. GravPoint = GravPoint - 1.9
  1055. end
  1056. if counter2 > 200 then
  1057. break
  1058. end
  1059. wait(0.02)
  1060. end
  1061.  
  1062. if VWallRunning == "LandingFall" then
  1063. print("Landing")
  1064.  
  1065. joint3.C1 = CFrame.new(0,1,0) * CFrame.Angles(0,math.pi/2,0)
  1066. joint4.C1 = CFrame.new(0,1,0) * CFrame.Angles(0,math.pi/2,0)
  1067. local j1,j1a = GetWeld(joint1)
  1068. local j2,j2a = GetWeld(joint2)
  1069. local j3,j3a = GetWeld(joint3)
  1070. local j4,j4a = GetWeld(joint4)
  1071. local j5,j5a = GetWeld(joint5)
  1072.  
  1073. local a
  1074. local mesh
  1075. if GravPoint < -70 then
  1076. a = P:Clone()
  1077. a.Parent = Torsoz
  1078. a.Name = "AirLandingEffect"
  1079. a.BrickColor = BrickColor.new("Medium stone grey")
  1080. a.Transparency = 0.3
  1081. a.CFrame = CFrame.new(landingpos+Vector3.new(0,0.4,0))
  1082. mesh = Instance.new("SpecialMesh", a)
  1083. mesh.MeshId = "http://www.roblox.com/asset/?id=20329976"
  1084. mesh.Scale = Vector3.new(0,0,0)
  1085. end
  1086.  
  1087. local bgcf = CFrame.new(NV, Vector3.new(towall.x,0,towall.z))
  1088. bg.cframe = bgcf * CFrame.Angles(-math.pi/7,0,0)
  1089. local bgval = math.pi/7/2
  1090.  
  1091. for i = 1, 6 do
  1092. Hu.PlatformStand = true
  1093. SetWeld(joint1,i,6, j1,j1a, Vector3.new(1.2,0.5,0.2), Vector3.new(math.pi/2,0.5,math.pi/1.2))
  1094. SetWeld(joint2,i,6, j2,j2a, Vector3.new(-1.2,0.5,0.2), Vector3.new(math.pi/2,-0.5,-math.pi/1.2))
  1095. SetWeld(joint3,i,6, j3,j3a, Vector3.new(0.51,-0.3,-0.8), Vector3.new(0,math.pi/2,-math.pi/7))
  1096. SetWeld(joint4,i,6, j4,j4a, Vector3.new(-0.51,-0.8,-0.7), Vector3.new(0,math.pi/2,-math.pi/3))
  1097. SetWeld(joint5,i,6, j5,j5a, Vector3.new(0,0.85,0), Vector3.new(-math.pi/8,0,0))
  1098. bp.position = bp.position + Vector3.new(0,-0.07,0)
  1099. bg.cframe = bgcf * CFrame.Angles((-bgval*2) + (bgval/6*i),0,0)
  1100. Torsoz.CFrame = bg.cframe + bp.position
  1101. if a ~= nil then
  1102. mesh.Scale = mesh.Scale + Vector3.new(1.3,0.35,1.3)
  1103. a.Transparency = 0.3 + (0.7/6*i)
  1104. end
  1105. wait(0.02)
  1106. end
  1107. if a ~= nil then
  1108. a:remove()
  1109. end
  1110. local j1,j1a = GetWeld(joint1)
  1111. local j2,j2a = GetWeld(joint2)
  1112. local j3,j3a = GetWeld(joint3)
  1113. local j4,j4a = GetWeld(joint4)
  1114. local j5,j5a = GetWeld(joint5)
  1115. for i = 1, 6 do
  1116. Hu.PlatformStand = true
  1117. SetWeld(joint1,i,6, j1,j1a, Vector3.new(1.5,0.5,0), Vector3.new(0,0,0))
  1118. SetWeld(joint2,i,6, j2,j2a, Vector3.new(-1.5,0.5,0), Vector3.new(0,0,0))
  1119. SetWeld(joint3,i,6, j3,j3a, Vector3.new(0.5,-1,0), Vector3.new(0,math.pi/2,0))
  1120. SetWeld(joint4,i,6, j4,j4a, Vector3.new(-0.5,-1,0), Vector3.new(0,math.pi/2,0))
  1121. SetWeld(joint5,i,6, j5,j5a, Vector3.new(0,1,0), Vector3.new(0,0,0))
  1122. bp.position = bp.position + Vector3.new(0,0.1,0)
  1123. bg.cframe = bgcf * CFrame.Angles(-bgval + (bgval/6*i),0,0)
  1124. Torsoz.CFrame = bg.cframe + bp.position
  1125. wait(0.02)
  1126. end
  1127.  
  1128. bp:remove()
  1129. end
  1130.  
  1131. end
  1132.  
  1133. bv:remove()
  1134. bg:remove()
  1135. VWallRunning = false
  1136. Stand()
  1137. end
  1138. end
  1139.  
  1140. function Slide(pos)
  1141. flow.Value = flow.Value + 6
  1142. Action = "Sliding"
  1143. Sliding = true
  1144. GravPoint = Torsoz.Velocity.y
  1145. local spd = Vector3.new(Torsoz.Velocity.x,0,Torsoz.Velocity.z).magnitude + 10
  1146. local dir = Vector3.new(Torsoz.Velocity.x,0,Torsoz.Velocity.z).unit
  1147.  
  1148. local bv = Instance.new("BodyVelocity", Torsoz)
  1149. bv.maxForce = Vector3.new(1/0,1/0,1/0)
  1150. bv.velocity = dir*spd
  1151. local bg = Instance.new("BodyGyro", Torsoz)
  1152. bg.maxTorque = Vector3.new(1/0,1/0,1/0)
  1153. bg.cframe = CFrame.new(NV, dir) * CFrame.Angles(math.pi/2.2,0.24,0)
  1154.  
  1155. local joint1 = Joint1
  1156. local joint2 = Joint2
  1157. local joint3 = Joint3
  1158. local joint4 = Joint4
  1159. local joint5 = Joint5
  1160. local j1,j1a = GetWeld(joint1)
  1161. local j2,j2a = GetWeld(joint2)
  1162.  
  1163. SetWeld(joint1,1,1, NV,NV, Vector3.new(j1.x,j1.y,j1.z), Vector3.new(j1a.x,math.pi/2,j1a.z))
  1164. joint1.C1 = CFrame.new(0,1,0) * CFrame.Angles(0,math.pi/2,0)
  1165. SetWeld(joint2,1,1, NV,NV, Vector3.new(j2.x,j2.y,j2.z), Vector3.new(j2a.x,math.pi/2,j2a.z))
  1166. joint2.C1 = CFrame.new(0,1,0) * CFrame.Angles(0,math.pi/2,0)
  1167.  
  1168. local j1,j1a = GetWeld(joint1)
  1169. local j2,j2a = GetWeld(joint2)
  1170. local j3,j3a = GetWeld(joint3)
  1171. local j4,j4a = GetWeld(joint4)
  1172. local j5,j5a = GetWeld(joint5)
  1173.  
  1174. local count = 0
  1175. local lastpos
  1176.  
  1177. while Sliding == true do
  1178. count = count + 1
  1179. Hu.PlatformStand = true
  1180. local hitz1, enz1 = RAY(Torsoz.Position+Vector3.new(0,0.03,0), dir *2.5)
  1181. local hitz2, enz2 = RAY(Torsoz.Position-Vector3.new(0,0.2,0), dir *2.5)
  1182. local ghitz, genz = RAY(Torsoz.Position, Vector3.new(0,-2.6,0))
  1183. bv.velocity = dir*spd + Vector3.new(0,GravPoint,0)
  1184.  
  1185. if count <= 5 then
  1186. SetWeld(joint1,count,5, j1,j1a, Vector3.new(0.5,-0.8,-0.15), Vector3.new(0,(math.pi/2)+0.1,-0.4))
  1187. SetWeld(joint2,count,5, j2,j2a, Vector3.new(-0.5,-1,0), Vector3.new(0,(math.pi/2)-0.4,0))
  1188. SetWeld(joint3,count,5, j3,j3a, Vector3.new(1.5,0.5,0), Vector3.new(-0.7,-0.24,math.pi/5))
  1189. SetWeld(joint4,count,5, j4,j4a, Vector3.new(-1.5,0.5,0), Vector3.new(-0.1,0,-math.pi/1.5))
  1190. SetWeld(joint5,count,5, j5,j5a, Vector3.new(0,1,0), Vector3.new(-0.5,-0.2,0))
  1191. end
  1192.  
  1193. if (hitz1 ~= nil and hitz1.CanCollide == true) or (hitz2 ~= nil and hitz2.CanCollide == true) then
  1194. bv:remove()
  1195. bg:remove()
  1196. Sliding = "HitObject"
  1197. end
  1198. if ghitz ~= nil then
  1199. GravPoint = 0
  1200. Torsoz.CFrame = CFrame.new(genz, genz+dir) * CFrame.Angles(math.pi/2.2,0.24,0) + Vector3.new(0,0.7,0)
  1201. spd = spd - 0.95
  1202. else
  1203. if GravPoint > -180 then
  1204. GravPoint = GravPoint - 5.6
  1205. end
  1206. spd = spd - 0.36
  1207. end
  1208. if spd < 7 then
  1209. Sliding = false
  1210. end
  1211. wait(0.02)
  1212. end
  1213.  
  1214. if Sliding == false then
  1215. local j1,j1a = GetWeld(joint1)
  1216. local j2,j2a = GetWeld(joint2)
  1217. local j3,j3a = GetWeld(joint3)
  1218. local j4,j4a = GetWeld(joint4)
  1219. local j5,j5a = GetWeld(joint5)
  1220. for i = 1, 4 do
  1221. SetWeld(joint1,i,4, j1,j1a, Vector3.new(0.5,-1,0), Vector3.new(0,math.pi/2,0))
  1222. SetWeld(joint2,i,4, j2,j2a, Vector3.new(-0.5,-1,0), Vector3.new(0,math.pi/2,0))
  1223. SetWeld(joint3,i,4, j3,j3a, Vector3.new(1.5,0.5,0), NV)
  1224. SetWeld(joint4,i,4, j4,j4a, Vector3.new(-1.5,0.5,0), NV)
  1225. SetWeld(joint5,i,4, j5,j5a, Vector3.new(0,1,0), NV)
  1226. local hitz, enz = RAY(Torsoz.Position, Vector3.new(0,-2.6,0))
  1227. bg.cframe = CFrame.new(NV, dir) * CFrame.Angles((math.pi/2.2) - ((math.pi/2.2)/4*i),0.24 - (0.24/4*i),0)
  1228. bv.velocity = dir*spd + Vector3.new(0,GravPoint,0)
  1229.  
  1230. if hitz ~= nil then
  1231. GravPoint = 0
  1232. Torsoz.CFrame = CFrame.new(enz, enz+dir) * CFrame.Angles((math.pi/2.2) - ((math.pi/2.2)/4*i),0.24 - (0.24/4*i),0) + Vector3.new(0,0.7+(1.8/4*i),0)
  1233. spd = spd - 0.95
  1234. else
  1235. if GravPoint > -180 then
  1236. GravPoint = GravPoint - 5.6
  1237. end
  1238. spd = spd - 0.36
  1239. end
  1240. wait(0.02)
  1241. end
  1242. local hitz, enz = RAY(Torsoz.Position, Vector3.new(0,-2.6,0))
  1243. Torsoz.CFrame = CFrame.new(enz, enz+dir) + Vector3.new(0,3,0)
  1244. end
  1245. bv:remove()
  1246. bg:remove()
  1247. SlideCooldown = 10
  1248. Stand()
  1249. end
  1250.  
  1251. function KD(key)
  1252. if pause.Value == false then
  1253. if key == string.char(32) then
  1254. Space = true
  1255.  
  1256. local ghitz, genz = RAY(Torsoz.Position, Vector3.new(0,-3.7,0))
  1257. local hitz, enz = RAY(Torsoz.Position+Vector3.new(0,1.1,0), Torsoz.CFrame.lookVector*2.3)
  1258. local righthitz, rightenz
  1259. local lefthitz, leftenz
  1260.  
  1261. if HWallRunning == false then
  1262. righthitz, rightenz = RAY(Torsoz.Position, ((Torsoz.CFrame * CFrame.new(1.5,0,-0.2)).p - Torsoz.CFrame.p).unit*3.9)
  1263. lefthitz, leftenz = RAY(Torsoz.Position, ((Torsoz.CFrame * CFrame.new(-1.5,0,-0.2)).p - Torsoz.CFrame.p).unit*3.9)
  1264.  
  1265. elseif HWallRunning == "Jumping" then
  1266. righthitz, rightenz = RAY(Torsoz.Position, ((CFrame.new(Torsoz.Position, Torsoz.Position + HWRDir) * CFrame.new(1.5,0,-0.2)).p - Torsoz.Position).unit*3.9)
  1267. lefthitz, leftenz = RAY(Torsoz.Position, ((CFrame.new(Torsoz.Position, Torsoz.Position + HWRDir) * CFrame.new(-1.5,0,-0.2)).p - Torsoz.Position).unit*3.9)
  1268.  
  1269. end
  1270.  
  1271. if Action == "Standing" and Shift == true and (hitz == nil or hitz.CanCollide == false) and (righthitz == nil or righthitz.CanCollide == false) and (lefthitz == nil or lefthitz.CanCollide == false) and (ghitz == nil or ghitz.CanCollide == false) and (Torsoz.Velocity.y > 6 and Torsoz.Velocity.y < 50) and DivingCooldown <= 0 then
  1272. if stamina >= 10 then
  1273. --if Vector3.new(Torsoz.Velocity.x,0,Torsoz.Velocity.z).magnitude > 12 then
  1274. Dive()
  1275. --end
  1276. end
  1277. end
  1278.  
  1279. if hitz == nil and VWallRunning == "Falling" then
  1280. VWallRunning = "BackflipFromFall"
  1281. end
  1282.  
  1283. if Shift == true and Torsoz.Velocity.y > -50 and Diving == false and DivingCooldown <= 0 then
  1284. local hitz2, enz2 = RAY(Torsoz.Position, Vector3.new(0,-3.5,0))
  1285.  
  1286. if hitz ~= nil then
  1287. if Action == "Standing" and VWRCooldown == 0 then
  1288. if hitz2 == nil or hitz2.CanCollide == false then
  1289. VWR(hitz, enz)
  1290. end
  1291. end
  1292. end
  1293.  
  1294. if (HWallRunning == false or (HWallRunning == "Jumping" and (HWRLastPart ~= righthitz or HWRLastPart ~= lefthitz))) and HWRCooldown == 0 and VWallRunning == false then
  1295.  
  1296. if (hitz == nil or HWallRunning == "Jumping") and ((righthitz ~= nil and righthitz.Parent:findFirstChild("Humanoid") == nil and righthitz.Parent.className ~= "Hat") or (lefthitz ~= nil and lefthitz.Parent:findFirstChild("Humanoid") == nil and lefthitz.Parent.className ~= "Hat")) then
  1297. if hitz2 == nil or hitz2.CanCollide == false then
  1298. local right = (rightenz - Torsoz.Position).magnitude
  1299. local left = (leftenz - Torsoz.Position).magnitude
  1300. if right < left then
  1301. if HWallRunning == "Jumping" and HWRLastPart ~= righthitz then
  1302. HWallRunning = false
  1303. while Standing == false do
  1304. wait(0.01)
  1305. end
  1306. print("2nd Right Activated!")
  1307. HWallRun(righthitz, rightenz, -math.pi/2)
  1308. else
  1309. if hitz == nil then
  1310. print("Right Activated")
  1311. HWallRun(righthitz, rightenz, -math.pi/2)
  1312. end
  1313. end
  1314. elseif left < right then
  1315. if HWallRunning == "Jumping" and HWRLastPart ~= lefthitz then
  1316. HWallRunning = false
  1317. while Standing == false do
  1318. wait(0.01)
  1319. end
  1320. print("2nd Left Activated!")
  1321. HWallRun(lefthitz, leftenz, math.pi/2)
  1322. else
  1323. if hitz == nil then
  1324. print("Left Activated")
  1325. HWallRun(lefthitz, leftenz, math.pi/2)
  1326. end
  1327. end
  1328. end
  1329. end
  1330. end
  1331. end
  1332.  
  1333. end
  1334.  
  1335. if HWallRunning == true then
  1336. HWallRunning = "Jumping"
  1337. Action = "HWRJumping"
  1338. end
  1339.  
  1340. elseif key == string.char(48) then
  1341. Shift = true
  1342. elseif key == string.char(50) then
  1343. if Action == "Standing" then
  1344. Sit()
  1345. elseif HWallRunning == true then
  1346. HWRGravDrop = true
  1347. end
  1348. elseif key == string.char(52) then
  1349. if Shift == true and Action == "Standing" and SlideCooldown == 0 and Vector3.new(Torsoz.Velocity.x,0,Torsoz.Velocity.z).magnitude > 15 and Torsoz.Velocity.y > -40 then
  1350. print("Sliding")
  1351. Slide()
  1352. end
  1353. elseif key == "a" then
  1354. VWRLeft = true
  1355. elseif key == "d" then
  1356. VWRRight = true
  1357. end
  1358. end
  1359. end
  1360.  
  1361. function KU(key)
  1362. if key == string.char(32) then
  1363. Space = false
  1364. elseif key == string.char(48) then
  1365. Shift = false
  1366. elseif key == string.char(50) then
  1367. if Action == "Sitting" then
  1368. Stand()
  1369. end
  1370. elseif key == string.char(52) then
  1371. Sliding = false
  1372. elseif key == "a" then
  1373. VWRLeft = false
  1374. elseif key == "d" then
  1375. VWRRight = false
  1376. end
  1377. end
  1378.  
  1379. mouse.KeyDown:connect(function(key) KD(key) end)
  1380. mouse.KeyUp:connect(function(key) KU(key) end)
  1381.  
  1382. Joint1 = Instance.new("Snap", Torsoz)
  1383. GetWeld(Joint1)
  1384. Joint2 = Instance.new("Snap", Torsoz)
  1385. GetWeld(Joint2)
  1386. Joint3 = Instance.new("Snap", Torsoz)
  1387. GetWeld(Joint3)
  1388. Joint4 = Instance.new("Snap", Torsoz)
  1389. GetWeld(Joint4)
  1390. Joint5 = Instance.new("Snap", Torsoz)
  1391. GetWeld(Joint5)
  1392. Stand()
  1393.  
  1394. local animatebg = Instance.new("BodyGyro")
  1395. animatebg.D = 100
  1396. local GravAction = "Idle"
  1397. local PrevGravAction = GravAction
  1398.  
  1399. local prevrapos = (RA.CFrame * CFrame.new(0,-1,0)).p
  1400. local prevlapos = (LA.CFrame * CFrame.new(0,-1,0)).p
  1401. local hue = 0
  1402. local recyclecount = 0
  1403. local tickoffset = tick()
  1404. local fadetab = {}
  1405. local fadetab2 = {}
  1406. local animatebgcount = 0
  1407.  
  1408. for i = 1, 13 do
  1409. local p = P:Clone()
  1410. p.Name = "Part"..i
  1411. local mesh = Instance.new("SpecialMesh", p)
  1412. mesh.MeshId = "http://www.roblox.com/Asset/?id=9856898"
  1413. mesh.TextureId = "http://www.roblox.com/Asset/?id=48358980"
  1414. table.insert(fadetab, {p, mesh})
  1415. end
  1416. for i = 1, 13 do
  1417. local p = P:Clone()
  1418. p.Name = "Part"..i
  1419. local mesh = Instance.new("SpecialMesh", p)
  1420. mesh.MeshId = "http://www.roblox.com/Asset/?id=9856898"
  1421. mesh.TextureId = "http://www.roblox.com/Asset/?id=48358980"
  1422. table.insert(fadetab2, {p, mesh})
  1423. end
  1424.  
  1425. game:service("RunService").Stepped:connect(function()
  1426. GravAction = "Idle"
  1427. hue = hue + 3
  1428. hue = hue % 360
  1429.  
  1430. ------------- anim angle changing --------
  1431. if animangle > math.pi then
  1432. animplus = false
  1433. elseif animangle < -math.pi then
  1434. animplus = true
  1435. end
  1436. if animplus == true then
  1437. animangle = animangle + animspeed
  1438. elseif animplus == false then
  1439. animangle = animangle - animspeed
  1440. end
  1441.  
  1442. local hitz, enz = RAY(Torsoz.Position, Vector3.new(0,-3.9,0))
  1443. if Shift == true then
  1444. Hu.WalkSpeed = sprint
  1445. else
  1446. Hu.WalkSpeed = 16
  1447. end
  1448. if (FOV >= 70 and FOV < 74) and Vector3.new(Torsoz.Velocity.x,0,Torsoz.Velocity.z).magnitude > 25 then
  1449. FOV = FOV + 1
  1450. elseif (FOV <= 74 and FOV > 70) and Vector3.new(Torsoz.Velocity.x,0,Torsoz.Velocity.z).magnitude < 20 then
  1451. FOV = FOV - 1
  1452. end
  1453. if pause.Value == true then
  1454. Hu.WalkSpeed = 0
  1455. end
  1456. if Sitting == true then
  1457. local hitz2, enz2 = RAY(Torsoz.Position, Vector3.new(0,-2.2,0))
  1458. Hu.PlatformStand = true
  1459. if hitz2 == nil then
  1460. Stand()
  1461. end
  1462. end
  1463. if Diving == true then
  1464. Hu.PlatformStand = true
  1465. DivingBV.velocity = Vector3.new(DivingDir.x*(sprint+2),GravPoint,DivingDir.z*(sprint+2))
  1466. DivingBG.cframe = CFrame.new(Torsoz.Position, Torsoz.Position+DivingBV.velocity) * CFrame.Angles(-math.pi/2,0,0)
  1467.  
  1468. if GravPoint > -180 then
  1469. GravPoint = GravPoint - 2
  1470. end
  1471. end
  1472. if DivingCooldown > 0 then
  1473. DivingCooldown = DivingCooldown - 1
  1474. end
  1475. if HWallRunning == true then
  1476. if HWRGravDrop == false then
  1477. GravPoint = GravPoint - 0.4
  1478. else
  1479. GravPoint = GravPoint - 2
  1480. end
  1481. elseif HWallRunning == "Jumping" then
  1482. GravPoint = GravPoint - 1.7
  1483. end
  1484. ----------------------------- stamina ----------------------------------------
  1485. if Vector3.new(Torsoz.Velocity.x, 0, Torsoz.Velocity.z).magnitude > 18 and Action == "Standing" and Shift == true then
  1486. if stamina > 0 then
  1487. stamina = stamina - 0.5
  1488. if stamina < 0 then
  1489. Shift = false
  1490. stamina = 0
  1491. end
  1492. else
  1493. Shift = false
  1494. stamina = 0
  1495. end
  1496. if Action == "Standing" then
  1497. animspeed = 0.85
  1498. SetWeld(Joint1,1,1, NV,NV, Vector3.new(0.5,-1,0), Vector3.new(-animangle/4.85,0,0))
  1499. SetWeld(Joint2,1,1, NV,NV, Vector3.new(-0.5,-1,0), Vector3.new(animangle/4.85,0,0))
  1500. SetWeld(Joint3,1,1, NV,NV, Vector3.new(1.5,0.5,0), Vector3.new(animangle/3.5,0,0))
  1501. SetWeld(Joint4,1,1, NV,NV, Vector3.new(-1.5,0.5,0), Vector3.new(-animangle/3.5,0,0))
  1502. end
  1503. elseif Vector3.new(Torsoz.Velocity.x, 0, Torsoz.Velocity.z).magnitude > 12 and Action ~= "Sliding" then
  1504. if stamina < maxstamina then
  1505. stamina = stamina + 0.5
  1506. if stamina > maxstamina then
  1507. stamina = maxstamina
  1508. end
  1509. else
  1510. stamina = maxstamina
  1511. end
  1512. if Action == "Standing" then
  1513. animspeed = 0.65
  1514. SetWeld(Joint1,1,1, NV,NV, Vector3.new(0.5,-1,0), Vector3.new(-animangle/7,0,0))
  1515. SetWeld(Joint2,1,1, NV,NV, Vector3.new(-0.5,-1,0), Vector3.new(animangle/7,0,0))
  1516. SetWeld(Joint3,1,1, NV,NV, Vector3.new(1.5,0.5,0), Vector3.new(animangle/5,0,0))
  1517. SetWeld(Joint4,1,1, NV,NV, Vector3.new(-1.5,0.5,0), Vector3.new(-animangle/5,0,0))
  1518. end
  1519. elseif Vector3.new(Torsoz.Velocity.x, 0, Torsoz.Velocity.z).magnitude < 2 then
  1520. animspeed = 0.1
  1521. if Action == "Standing" then
  1522. SetWeld(Joint1,1,1, NV,NV, Vector3.new(0.5,-1,0), Vector3.new(-animangle/38,0,0))
  1523. SetWeld(Joint2,1,1, NV,NV, Vector3.new(-0.5,-1,0), Vector3.new(animangle/38,0,0))
  1524. SetWeld(Joint3,1,1, NV,NV, Vector3.new(1.5,0.5,0), Vector3.new(animangle/30,0,0))
  1525. SetWeld(Joint4,1,1, NV,NV, Vector3.new(-1.5,0.5,0), Vector3.new(-animangle/30,0,0))
  1526. end
  1527. if stamina < maxstamina then
  1528. if Sitting == false then
  1529. stamina = stamina + 0.65
  1530. else
  1531. stamina = stamina + 1.02
  1532. end
  1533. if stamina > maxstamina then
  1534. stamina = maxstamina
  1535. end
  1536. else
  1537. stamina = maxstamina
  1538. end
  1539. end
  1540.  
  1541. if hitz == nil then
  1542. if Torsoz.Velocity.y > 1 or (Torsoz.Velocity.y < -1 and Torsoz.Velocity.y > -90) then
  1543. if Action == "Standing" then
  1544. GravAction = "Rising"
  1545. animspeed = 0.1
  1546. SetWeld(Joint1,1,1, NV,NV, Vector3.new(0.5,-1,0), Vector3.new(-animangle/38,0,0))
  1547. SetWeld(Joint2,1,1, NV,NV, Vector3.new(-0.5,-1,0), Vector3.new(animangle/38,0,0))
  1548. SetWeld(Joint3,1,1, NV,NV, Vector3.new(1.5,0.5,0), Vector3.new((math.pi-0.2)+(animangle/30),0,0))
  1549. SetWeld(Joint4,1,1, NV,NV, Vector3.new(-1.5,0.5,0), Vector3.new((math.pi-0.2)+(-animangle/30),0,0))
  1550. if animatebg.Parent ~= nil then
  1551. animatebg.Parent = Torsoz
  1552. animatebg.maxTorque = Vector3.new(1/0,10000,1/0)
  1553. local lokvec = Torsoz.CFrame.lookVector*100
  1554. animatebg.cframe = CFrame.new(NV, Vector3.new(lokvec.x,0,lokvec.z))
  1555. animatebg.Parent = nil
  1556. end
  1557. end
  1558. end
  1559. end
  1560.  
  1561. if hitz == nil then
  1562. local hitz2, enz2 = RAY(Torsoz.Position, Vector3.new(0,-6,0))
  1563. if hitz2 == nil then
  1564. if Torsoz.Velocity.y < -90 then
  1565. if Action == "Standing" then
  1566. GravAction = "Falling"
  1567. animspeed = 1.1
  1568. animatebg.Parent = Torsoz
  1569. animatebg.maxTorque = Vector3.new(1/0,10000,1/0)
  1570. local lokvec = Torsoz.CFrame.lookVector*100
  1571. animatebg.cframe = CFrame.new(NV, Vector3.new(lokvec.x,0,lokvec.z)) * CFrame.Angles(-math.pi/11,animangle/70,0)
  1572. SetWeld(Joint1,1,1, NV,NV, Vector3.new(0.45,-0.8,0), Vector3.new((animangle/27)-0.3,0,0.18))
  1573. SetWeld(Joint2,1,1, NV,NV, Vector3.new(-0.45,-0.8,0), Vector3.new((-animangle/27)-0.3,0,-0.18))
  1574. SetWeld(Joint3,1,1, NV,NV, Vector3.new(1.4,0.5,0), Vector3.new((math.pi+0.2)+(animangle/26),0,0.18))
  1575. SetWeld(Joint4,1,1, NV,NV, Vector3.new(-1.4,0.5,0), Vector3.new((math.pi+0.2)+(-animangle/26),0,-0.18))
  1576. end
  1577. end
  1578. elseif hitz2.CanCollide == true then
  1579. if animatebg.Parent ~= nil then
  1580. animatebg.Parent = Torsoz
  1581. animatebg.maxTorque = Vector3.new(1/0,10000,1/0)
  1582. local lokvec = Torsoz.CFrame.lookVector*100
  1583. animatebg.cframe = CFrame.new(NV, Vector3.new(lokvec.x,0,lokvec.z))
  1584. animatebg.Parent = nil
  1585. end
  1586. end
  1587. end
  1588.  
  1589. if GravAction == "Idle" and animatebg.Parent ~= nil then
  1590. animatebg.Parent = nil
  1591. end
  1592.  
  1593. if math.abs(tickoffset - tick()) > 0.05 then
  1594. tickoffset = tick()
  1595. local flowcolor = HSV(hue, 0.7,1)
  1596. recyclecount = (recyclecount % #fadetab) + 1
  1597. if flow.Value > 25 then
  1598. local lapos = (LA.CFrame * CFrame.new(0,-1,0)).p
  1599. local rapos = (RA.CFrame * CFrame.new(0,-1,0)).p
  1600. local p = fadetab[recyclecount]
  1601. p[1].Parent = m
  1602. p[1].CFrame = CFrame.new((lapos+prevlapos)/2, lapos)
  1603. p[2].Scale = Vector3.new(0.5,0.5,(lapos-prevlapos).magnitude*2)
  1604. p[2].VertexColor = Vector3.new(flowcolor.r,flowcolor.g,flowcolor.b)
  1605. p[1].Transparency = math.abs((flow.Value/120) - 0.8)
  1606. p[1].Transparency = p[1].Transparency + (1/#fadetab)
  1607. local p = fadetab2[recyclecount]
  1608. p[1].Parent = m
  1609. p[1].CFrame = CFrame.new((rapos+prevrapos)/2, rapos)
  1610. p[2].Scale = Vector3.new(0.5,0.5,(rapos-prevrapos).magnitude*2)
  1611. p[2].VertexColor = Vector3.new(flowcolor.r,flowcolor.g,flowcolor.b)
  1612. p[1].Transparency = math.abs((flow.Value/120) - 0.8)
  1613. p[1].Transparency = p[1].Transparency + (1/#fadetab)
  1614. end
  1615.  
  1616. for i, v in pairs(fadetab) do
  1617. if v[1].Transparency < 0.9 then
  1618. v[1].Transparency = v[1].Transparency + (1/#fadetab)
  1619. fadetab2[i][1].Transparency = fadetab2[i][1].Transparency + (1/#fadetab)
  1620. elseif v[1].Transparency ~= 1 then
  1621. v[1].Transparency = 1
  1622. v[1].Position = Vector3.new(50000,0,0)
  1623. fadetab2[i][1].Transparency = 1
  1624. fadetab2[i][1].Position = Vector3.new(50000,0,0)
  1625. end
  1626. end
  1627.  
  1628. prevrapos = (RA.CFrame * CFrame.new(0,-1,0)).p
  1629. prevlapos = (LA.CFrame * CFrame.new(0,-1,0)).p
  1630. end
  1631.  
  1632. if flow.Value > 140 then
  1633. if char.Parent ~= nil then
  1634. char:remove()
  1635. end
  1636. end
  1637.  
  1638. if flowcooldown > 0 then
  1639. flowcooldown = flowcooldown - 1
  1640. end
  1641. if HWRCooldown > 0 then
  1642. HWRCooldown = HWRCooldown - 1
  1643. end
  1644. if VWRCooldown > 0 then
  1645. if hitz ~= nil and VWRCooldown > 0 then
  1646. VWRCooldown = VWRCooldown - 1
  1647. end
  1648. end
  1649. if SlideCooldown > 0 then
  1650. SlideCooldown = SlideCooldown - 1
  1651. end
  1652.  
  1653. if Action == "HWallRunning" or Action == "VWallRunning" then
  1654. flow.Value = flow.Value + 0.24
  1655. if flow.Value > 100 then
  1656. flow.Value = 100
  1657. end
  1658. flowcooldown = 40
  1659. elseif Action == "Diving" then
  1660. flowcooldown = 30
  1661. elseif Action == "Sliding" then
  1662. flowcooldown = 15
  1663. elseif Action == "Standing" or Action == "Sitting" then
  1664. if flow.Value > 0 and flowcooldown <= 0 then
  1665. flow.Value = flow.Value - 0.37
  1666. if flow.Value < 0 then
  1667. flow.Value = 0
  1668. end
  1669. end
  1670. end
  1671.  
  1672. cam.FieldOfView = FOV
  1673. prevanimbgcount = animatebgcount
  1674. sprint = defsprint + ((flow.Value/100)*2.4)
  1675. PrevGravAction = GravAction
  1676. Calculate()
  1677. end)
  1678.  
  1679. --[[
  1680. Smith and Wesson M&P 45, chambered in .45 ACP ammunition.
  1681. The standard magazine holds 10 rounds, although magazines that could hold 14 rounds were also made but looked incredibly stupid.
  1682. Credit to litozinnamon for the crosshairs and bullethole decals. I used them without permission. Not like I asked him, anyhow.
  1683. ]]
  1684.  
  1685. plr=game:service'Players'.LocalPlayer
  1686. ch,char=plr.Character,plr.Character
  1687. hum=ch.Humanoid
  1688. tor,torso,rootpart,rj=ch.Torso,ch.Torso,ch.HumanoidRootPart,ch.HumanoidRootPart.RootJoint
  1689. m,mouse=plr:GetMouse(),plr:GetMouse()
  1690. cfn,ang,mr,int=CFrame.new,CFrame.Angles,math.rad,Instance.new
  1691. bc=BrickColor.new
  1692. head=ch.Head
  1693. cam=workspace.CurrentCamera
  1694.  
  1695. rj.C0=cfn()
  1696. rj.C1=cfn()
  1697.  
  1698. sheathed=false
  1699. jammed=false
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711. local minimumsize = Vector3.new(0.7,0.7,0.7) --Minimumsize for a part to get divided,higher numbers = less detailed and bigger/less bricks
  1712. local surface_between_splitted_parts = 'SmoothNoOutlines' --the surface between splitted parts
  1713. --local fragmented = workspace:FindFirstChild("Fragmented")
  1714. local fragmentable = workspace --all fragmentable objects should be stored in here
  1715. local list = {}
  1716. local brickcount = 0
  1717. --local m = Instance.new("Hint",workspace)
  1718. local storage = {}
  1719. local fillup = 1000 --it constantly generates new parts until it reaches this number(hacky way to prevent lagspikes if there is a large explosion),change it to 0 if you don´t want it to generate (useless) parts.
  1720. local maximumstorage = 2000 --it will recycle parts if the number of parts in the storage doesnt exceed this number
  1721. local storage_position = Vector3.new(0,0,5000) --place them somewhere off the map
  1722. local stored_partsize = Vector3.new(1,1,1) --make them small
  1723. local parts_created_per_frame = 5 --number of parts being created per frame to fill up the storage
  1724.  
  1725.  
  1726. function fragmentate(cframe,size,color,explosion_position,explosion_blastradius,backsurface,bottomsurface,frontsurface,leftsurface,rightsurface,topsurface,transparency,reflectance)
  1727. local xi = size.X >= minimumsize.X*(1+explosion_blastradius/16) and 2 or 1 --to reduce the lagg in large explosions we increase minimumsize based on the explosionradius...
  1728. local yi = size.Y >= minimumsize.Y*(1+explosion_blastradius/16) and 2 or 1
  1729. local zi = size.Z >= minimumsize.Z*(1+explosion_blastradius/16) and 2 or 1
  1730. if xi == 1 and yi == 1 and zi == 1 or (cframe.p-explosion_position).magnitude > size.magnitude/2 + explosion_blastradius then --don´t fragmentate parts, that are too small to fragmentate or too far away from the explosion
  1731. if xi == 1 and yi == 1 and zi == 1 then return end --optional
  1732. if #storage > 0 then
  1733. local p = storage[1]
  1734. p.BrickColor = color
  1735. p.Size = size
  1736. p.BackSurface = backsurface
  1737. p.BottomSurface = bottomsurface
  1738. p.FrontSurface = frontsurface
  1739. p.LeftSurface = leftsurface
  1740. p.RightSurface = rightsurface
  1741. p.TopSurface = topsurface
  1742. p.Transparency = transparency
  1743. p.CFrame = cframe
  1744. p.Reflectance = reflectance
  1745. table.remove(storage,1)
  1746. else
  1747. local p = Instance.new("Part",fragmentable)
  1748. p.BrickColor = color
  1749. p.FormFactor = "Custom"
  1750. p.Size = size
  1751. p.BackSurface = backsurface
  1752. p.BottomSurface = bottomsurface
  1753. p.FrontSurface = frontsurface
  1754. p.LeftSurface = leftsurface
  1755. p.RightSurface = rightsurface
  1756. p.TopSurface = topsurface
  1757. p.Transparency = transparency
  1758. if p.Transparency>0.285 then
  1759. p.Anchored = false
  1760. else
  1761. p.Anchored=true
  1762. p.Material='Wood'
  1763. end
  1764. p.CFrame = cframe
  1765. p.Reflectance = reflectance
  1766. end
  1767. --p:MakeJoints()
  1768. -- m.Text = m.Text+1
  1769. return --stop the function
  1770. end
  1771. local mody = math.random(-125,125)/1000 --some randomization
  1772. for y = 1,yi do
  1773. if math.random()> 0.5 then
  1774. local modx = math.random(-125,125)/1000
  1775. for x = 1,xi do
  1776. local modz = math.random(-125,125)/1000
  1777. for z = 1,zi do --offset = x/xi-0.75+modx)
  1778. fragmentate(cframe*CFrame.new(size.X*(xi==1 and 0 or x/xi-0.75+modx),size.Y*(yi==1 and 0 or y/yi-0.75+mody),size.Z*(zi==1 and 0 or z/zi-0.75+modz)), --maths
  1779. Vector3.new(xi == 2 and size.X*(1-2*math.abs(x/xi-0.75+modx)) or size.X,yi == 2 and size.Y*(1-2*math.abs(y/yi-0.75+mody)) or size.Y,
  1780. zi == 2 and size.Z*(1-2*math.abs(z/zi-0.75+modz)) or size.Z or agent767_was_here),color,explosion_position,explosion_blastradius,
  1781. z~=zi and surface_between_splitted_parts or backsurface,y==2 and surface_between_splitted_parts or bottomsurface,
  1782. z==2 and surface_between_splitted_parts or frontsurface,x==2 and surface_between_splitted_parts or leftsurface,x~=xi and surface_between_splitted_parts or rightsurface,
  1783. y~=yi and surface_between_splitted_parts or topsurface,transparency,reflectance)
  1784. end
  1785.  
  1786. end
  1787. else
  1788. local modz = math.random(-125,125)/1000
  1789. for z = 1,zi do
  1790. local modx = math.random(-125,125)/1000
  1791. for x = 1,xi do
  1792. fragmentate(cframe*CFrame.new(size.X*(xi==1 and 0 or x/xi-0.75+modx),size.Y*(yi==1 and 0 or y/yi-0.75+mody),size.Z*(zi==1 and 0 or z/zi-0.75+modz)),
  1793. Vector3.new(xi == 2 and size.X*(1-2*math.abs(x/xi-0.75+modx)) or size.X,yi == 2 and size.Y*(1-2*math.abs(y/yi-0.75+mody)) or size.Y,
  1794. zi == 2 and size.Z*(1-2*math.abs(z/zi-0.75+modz)) or size.Z),color,explosion_position,explosion_blastradius,
  1795. z~=zi and surface_between_splitted_parts or backsurface,y==2 and surface_between_splitted_parts or bottomsurface,
  1796. z==2 and surface_between_splitted_parts or frontsurface,x==2 and surface_between_splitted_parts or leftsurface,x~=xi and surface_between_splitted_parts or rightsurface,
  1797. y~=yi and surface_between_splitted_parts or topsurface,transparency,reflectance)
  1798. end
  1799. end
  1800. end
  1801. end
  1802. end
  1803.  
  1804. function start_fragmentation(position,radius)
  1805. local search = Region3.new(position-Vector3.new(radius,radius,radius)*1.1,position+Vector3.new(radius,radius,radius)*1.1)
  1806. repeat
  1807. local finish = false
  1808. local parts = workspace:FindPartsInRegion3WithIgnoreList(search,list,100) --maximum number of parts that FindPartsInRegion3 can find is 100, so we have to do this to find them all
  1809. for i = 1,#parts do
  1810. table.insert(list,1,parts[i])
  1811. end
  1812. finish = true
  1813. until #parts < 100 and finish
  1814. print(#list)
  1815. local t = tick()
  1816. for i = 1,#list do
  1817. local p = list[i]
  1818. if p:IsDescendantOf(fragmentable) and p:GetMass()<3000 and p.Transparency>0.285 and p.Name~='Base' and p:IsDescendantOf(ch)==false then
  1819. fragmentate(p.CFrame,p.Size,p.BrickColor,position,radius,p.BackSurface,p.BottomSurface,p.FrontSurface,p.LeftSurface,p.RightSurface,p.TopSurface,p.Transparency,p.Reflectance)
  1820. if #storage < maximumstorage and p.Shape == "Block" then --recycle them
  1821. p.Anchored = false
  1822. p.FormFactor = "Custom"
  1823. p.Size = stored_partsize
  1824. p.Position = storage_position
  1825. table.insert(storage,1,p)
  1826. else --storage is full
  1827. p:Destroy()
  1828. end
  1829. -- m.Text = m.Text-1
  1830. end
  1831. if p:IsDescendantOf(fragmentable) and p:GetMass()<53000 and p.Transparency<0.05 and p.Name~='Base' and tostring(p.Material)=='Enum.Material.Wood' and p:IsDescendantOf(ch)==false then
  1832. fragmentate(p.CFrame,p.Size,p.BrickColor,position,radius,p.BackSurface,p.BottomSurface,p.FrontSurface,p.LeftSurface,p.RightSurface,p.TopSurface,p.Transparency,p.Reflectance)
  1833. if #storage < maximumstorage and p.Shape == "Block" then --recycle them
  1834. p.Anchored = true
  1835. p.Material='Wood'
  1836. p.FormFactor = "Custom"
  1837. p.Size = stored_partsize
  1838. p.Position = storage_position
  1839. table.insert(storage,1,p)
  1840. else --storage is full
  1841. p:Destroy()
  1842. end
  1843. -- m.Text = m.Text-1
  1844. end
  1845. end
  1846. list = {}
  1847. -- print(tick()-t)
  1848. end
  1849.  
  1850. --[[
  1851. spawn(function()
  1852. while wait() do --oh noes,a loop! So inefficient!
  1853. if #storage < fillup then
  1854. for i = 1, parts_created_per_frame do --creates parts to fill up the storage
  1855. local p = Instance.new("Part",fragmentable)
  1856. p.Anchored = false
  1857. p.FormFactor = "Custom"
  1858. p.Size = stored_partsize
  1859. p.Position = storage_position
  1860. table.insert(storage,1,p)
  1861. end
  1862. end
  1863. end
  1864. end)
  1865. ]]
  1866.  
  1867.  
  1868.  
  1869.  
  1870.  
  1871.  
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  
  1880.  
  1881.  
  1882.  
  1883.  
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889. --local blankn=22416261
  1890.  
  1891. --172121567
  1892.  
  1893. crosshairs={
  1894. {38140824};
  1895. {38140833};
  1896. {38140839};
  1897. {38140843};
  1898. {38140852};
  1899. {38140910};
  1900. {38140915};
  1901. {38140923};
  1902. {38140928};
  1903. {38140931};
  1904. {38208259};
  1905. {38208275};
  1906. {38208284};
  1907. {38208303};
  1908. {38208310};
  1909. {38208325};
  1910. {38208330};
  1911. {38208352};
  1912. {38208359};
  1913. {38208377}
  1914. }
  1915.  
  1916. bulletholes={
  1917. 172274695;
  1918. 172274721
  1919. }
  1920.  
  1921. for _,v in pairs(crosshairs) do
  1922. game:service'ContentProvider':Preload('rbxassetid://' .. tostring(v[1]-1))
  1923. end
  1924.  
  1925. currentIco=2
  1926. switchIco=function(num)
  1927. if num<20 then
  1928. else
  1929. num=20
  1930. end
  1931. mouse.Icon='rbxassetid://' .. tostring(crosshairs[num][1]-1)
  1932. currentIco=num
  1933. end
  1934.  
  1935. switchIco(currentIco)
  1936.  
  1937. heldDown=false
  1938.  
  1939. spreadint=1
  1940. --[[Settings]]--
  1941. recoil=false -- Set to true for added realism
  1942. magCapacity=20 -- How much a magazine can hold at once
  1943. magAmmo=20 -- How much ammo is in the mag
  1944. crosshairSpread=5
  1945. spread=1
  1946. pAmmunition=true -- more damage if true
  1947.  
  1948.  
  1949. jamRate=500 -- How often the gun jams(the more the less) (no less than 1)
  1950.  
  1951. primaryColor='Really black'
  1952. secondaryColor='Really black'
  1953.  
  1954. slideReflectance=0.01
  1955. slideMaterial='Plastic'
  1956.  
  1957. --[[Attachments]]--
  1958.  
  1959. silencer=true
  1960. highCapMag=false -- High capacity magazine
  1961. laser=true
  1962. automatic=false
  1963. grip=true
  1964.  
  1965.  
  1966. getSound=function(id)
  1967. game:service'ContentProvider':Preload('rbxassetid'..tostring(id))
  1968. local s=int("Sound",ch.Head)
  1969. s.SoundId='rbxassetid://' .. tostring(id)
  1970. s.Volume=1
  1971. return s
  1972. end
  1973.  
  1974. local fireSound=getSound(151997297--[[10209842]])
  1975. fireSound.Pitch=1.3
  1976. --1.8
  1977.  
  1978. local releaseSound=getSound(10209813)
  1979. releaseSound.Pitch=4
  1980.  
  1981. local reloadSound=getSound(10209636)
  1982. reloadSound.Pitch=3
  1983.  
  1984. local magazinelockSound=getSound(152206337)
  1985. magazinelockSound.Pitch=1.4
  1986.  
  1987. local slideBackSound=getSound(152206263)
  1988. slideBackSound.Pitch=2.5
  1989.  
  1990. local slideForwardSound=getSound(152206302)
  1991. slideForwardSound.Pitch=2.5
  1992.  
  1993. local emptySound=getSound(2697295)
  1994. emptySound.Pitch=5
  1995.  
  1996. local glassBreakSound=getSound(144884907)
  1997.  
  1998. local woodImpact=getSound(142082171)
  1999.  
  2000. local fleshImpact=getSound(144884872)
  2001. fleshImpact.Pitch=1.7
  2002.  
  2003. if ch:findFirstChild("Tec-99") then
  2004. ch['Tec-99']:Destroy()
  2005. end
  2006.  
  2007. local tube=int("Model",ch)
  2008. tube.Name='Tec-99'
  2009. local hopper=Instance.new('HopperBin',plr.Backpack)
  2010. hopper.Name=tube.Name
  2011. Weld = function(p0,p1,x,y,z,rx,ry,rz,par)--recommend to use this with my weld. use this function only with arm lockers.
  2012. p0.Position = p1.Position
  2013. local w = Instance.new('Motor',par or p0)
  2014. w.Part0 = p1
  2015. w.Part1 = p0
  2016. w.C0 = CFrame.new(x or 0,y or 0,z or 0)*CFrame.Angles(rx or 0,ry or 0,rz or 0)
  2017. w.MaxVelocity = .1
  2018. return w
  2019. end
  2020. function clerp(c1,c2,sp)
  2021. local R1,R2,R3 = c1:toEulerAnglesXYZ()
  2022. local R21,R22,R23 = c2:toEulerAnglesXYZ()
  2023. return CFrame.new(
  2024. c1.X + (c2.X-c1.X)*sp,
  2025. c1.Y + (c2.Y-c1.Y)*sp,
  2026. c1.Z + (c2.Z-c1.Z)*sp)*CFrame.Angles(
  2027. R1 + (R21-R1)*sp,
  2028. R2 + (R22-R2)*sp,
  2029. R3 + (R23-R3)*sp
  2030. )
  2031. end
  2032.  
  2033. tweenTable={}
  2034. Tween = function(Weld, Stop, Step,a)
  2035. ypcall(function()
  2036. local func = function()
  2037. local Start = Weld.C1
  2038. local X1, Y1, Z1 = Start:toEulerAnglesXYZ()
  2039. local Stop = Stop
  2040. local X2, Y2, Z2 = Stop:toEulerAnglesXYZ()
  2041. if not Step then Step=0.1 end
  2042. table.insert(tweenTable,{th=0,Weld=Weld,Step=Step,Start=Start,X1=X1,Y1=Y1,Z1=Z1,Stop=Stop,X2=X2,Y2=Y2,Z2=Z2})
  2043. end
  2044. if a then coroutine.wrap(func)() else func() end
  2045. end)
  2046. end
  2047. weld=function(p0,p1,c0)
  2048. local w=Instance.new("Weld",p0)
  2049. w.Part0=p0
  2050. w.Part1=p1
  2051. w.C0=c0
  2052. return w
  2053. end
  2054. cp=function(parent,color,size,anchored,cancollide)
  2055. local newp=Instance.new("Part",parent)
  2056. newp.TopSurface='SmoothNoOutlines'
  2057. newp.BottomSurface='SmoothNoOutlines'
  2058. newp.FrontSurface='SmoothNoOutlines'
  2059. newp.BackSurface='SmoothNoOutlines'
  2060. newp.RightSurface='SmoothNoOutlines'
  2061. newp.LeftSurface='SmoothNoOutlines'
  2062. newp.FormFactor="Custom"
  2063. newp.BrickColor=bc(color)
  2064. newp.Size=size
  2065. newp.Anchored=anchored
  2066. newp.CanCollide=cancollide
  2067. newp:BreakJoints()
  2068. return newp
  2069. end
  2070.  
  2071. initializeJoints=function()
  2072. rabr = cp(tube,'White',Vector3.new(1,1,1),false,false) rabr.Transparency = 1 rabr.Name='Locker'
  2073. rabr.Position = torso.Position
  2074. rw = Weld(rabr,torso,1.5,.5,0,0,0,0) rw.Parent = tube rw.Name = 'rw'
  2075. w = Instance.new("Weld",tube)
  2076. w.Part0,w.Part1 = ch['Right Arm'],rabr
  2077. w.C1 = CFrame.new(0,-.5,0)
  2078. labr = cp(tube,'White',Vector3.new(1,1,1),false,false) labr.Transparency = 1 labr.Name='Locker'
  2079. labr.Position = torso.Position
  2080. lw = Weld(labr,torso,-1.5,.5,0,0,0,0) lw.Parent = tube lw.Name = 'lw'
  2081. ww = Instance.new("Weld",tube)
  2082. ww.Part0,ww.Part1 = ch['Left Arm'],labr
  2083. ww.C1 = CFrame.new(0,-.5,0)
  2084. end
  2085.  
  2086. initializeJoints()
  2087.  
  2088. --[[ leg locks
  2089. rabl = cp(tube,'White',Vector3.new(1,1,1),false,false) rabl.Transparency = 1 rabl.Name='Locker'
  2090. rabl.Position = torso.Position
  2091. rwl = Weld(rabl,torso,0.5,-1.5,0,0,0,0) rwl.Parent = tube rwl.Name = 'rwl'
  2092. wl = Instance.new("Weld",tube)
  2093. wl.Part0,wl.Part1 = ch['Right Leg'],rabl
  2094. wl.C1 = CFrame.new(0,-.5,0)
  2095. labl = cp(tube,'White',Vector3.new(1,1,1),false,false) labl.Transparency = 1 labl.Name='Locker'
  2096. labl.Position = torso.Position
  2097. lwl = Weld(labl,torso,-0.5,-1.5,0,0,0,0) lwl.Parent = tube lwl.Name = 'lwl'
  2098. wwl = Instance.new("Weld",tube)
  2099. wwl.Part0,wwl.Part1 = ch['Left Leg'],labl
  2100. wwl.C1 = CFrame.new(0,-.5,0)
  2101. ]]
  2102. --weld(ch['HumanoidRootPart'],torso,cfn())
  2103.  
  2104.  
  2105. local counter=Instance.new('ScreenGui',plr.PlayerGui)
  2106. local frame=Instance.new('Frame',counter)
  2107. frame.Size=UDim2.new(0.25,0,0.3,0)
  2108.  
  2109. frame.Position=UDim2.new(0.1,0,0.4,0)
  2110. frame.BackgroundTransparency=1
  2111.  
  2112. local ammocounter=Instance.new('TextLabel',frame)
  2113. ammocounter.Size=UDim2.new(1,0,0.3,0)
  2114. ammocounter.Position=UDim2.new(0,0,0.2,0)
  2115. ammocounter.BackgroundTransparency=1
  2116. ammocounter.TextColor3=BrickColor.new('White').Color
  2117. ammocounter.Font='SourceSansBold'
  2118. ammocounter.FontSize='Size18'
  2119. ammocounter.Text=''
  2120. ammocounter.TextXAlignment='Left'
  2121.  
  2122.  
  2123. local bg = Instance.new("BodyGyro",rootpart)
  2124. bg.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
  2125. bg.P = 10000
  2126. bg.D = 100
  2127.  
  2128.  
  2129. cyl=function(prt)
  2130. local c=int("CylinderMesh",prt)
  2131. return c
  2132. end
  2133. blo=function(prt)
  2134. local c=int("BlockMesh",prt)
  2135. return c
  2136. end
  2137.  
  2138. if laser then
  2139. aLaser=cp(tube,'Really red',Vector3.new(0.2,0.2,0.2))
  2140. aLaser.Transparency=1
  2141. cyl(aLaser).Scale=Vector3.new(0.25,1,0.25)
  2142. aLaser.Anchored=true
  2143. end
  2144.  
  2145. local handle=cp(tube,primaryColor,Vector3.new(0.2,0.6,0.3))
  2146. blo(handle).Scale=Vector3.new(1.15,0.9,1)
  2147. local mw=weld(ch['Right Arm'],handle,cfn(-0.4,-1,-0.19)*ang(mr(-101.5),0,0)*cfn()*ang(0,mr(-30),mr(-5)))
  2148.  
  2149. local framepiece1=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.9))
  2150. blo(framepiece1).Scale=Vector3.new(1.15,0.5,1)
  2151. weld(handle,framepiece1,cfn(0,0.354,-0.3)*ang(mr(11.5),0,0))
  2152.  
  2153. local barrel=cp(tube,'Medium stone grey',Vector3.new(0.2,0.2,0.2))
  2154. cyl(barrel).Scale=Vector3.new(0.7,1.2,0.7)
  2155. weld(framepiece1,barrel,cfn(0,0.15,-0.1)*ang(mr(-90),0,0))
  2156.  
  2157. local sbarrel=cp(tube,'Really black',Vector3.new(0.2,0.3,0.2))
  2158. cyl(sbarrel).Scale=Vector3.new(0.7,1.5,0.7)
  2159. weld(barrel,sbarrel,cfn(0,0.35,0))
  2160. local hole=cp(tube,'White',Vector3.new(0.2,0.2,0.2))
  2161. hole.Transparency=1
  2162. weld(sbarrel,hole,cfn(0,0.2,0))
  2163. local flash=int('PointLight',hole)
  2164. flash.Enabled=false
  2165. flash.Range=10
  2166. flash.Color=BrickColor.new('Neon orange').Color
  2167.  
  2168.  
  2169. local slide1=cp(tube,secondaryColor,Vector3.new(0.2,0.2,0.4))
  2170. slide1.CanCollide=false
  2171. blo(slide1).Scale=Vector3.new(0.7,1,1.1)
  2172. slideweld1=weld(framepiece1,slide1,cfn(0,0.15,0.23))
  2173. slide1.Reflectance=slideReflectance
  2174. slide1.Material=slideMaterial
  2175.  
  2176. local slide2=cp(tube,secondaryColor,Vector3.new(0.2,0.2,0.4))
  2177. slide2.CanCollide=false
  2178. blo(slide2).Scale=Vector3.new(0.7,1,1.1)
  2179. slideweld2=weld(slide1,slide2,cfn(0,0,-0.666))
  2180. slide2.Reflectance=slideReflectance
  2181. slide2.Material=slideMaterial
  2182.  
  2183. local slideside1=cp(tube,secondaryColor,Vector3.new(0.2,0.2,1.1))
  2184. slideside1.CanCollide=true
  2185. blo(slideside1).Scale=Vector3.new(0.25,1,1)
  2186. weld(slide1,slideside1,cfn(-0.09,0,-0.335))
  2187. slideside1.Reflectance=slideReflectance
  2188. slideside1.Material=slideMaterial
  2189.  
  2190. local slideside2=cp(tube,secondaryColor, Vector3.new(0.2,0.2,0.4))
  2191. slideside2.CanCollide=true
  2192. blo(slideside2).Scale=Vector3.new(0.25,1,1.1)
  2193. weld(slide1,slideside2,cfn(0.09,0,0))
  2194. slideside2.Reflectance=slideReflectance
  2195. slideside2.Material=slideMaterial
  2196.  
  2197. local slideside3=cp(tube,secondaryColor, Vector3.new(0.2,0.2,0.3))
  2198. slideside3.CanCollide=true
  2199. blo(slideside3).Scale=Vector3.new(0.25,0.6,0.78)
  2200. weld(slideside2,slideside3,cfn(0,-0.04,-0.335))
  2201. slideside3.Reflectance=slideReflectance
  2202. slideside3.Material=slideMaterial
  2203.  
  2204. local slideside4=cp(tube,secondaryColor, Vector3.new(0.2,0.2,0.4))
  2205. blo(slideside4).Scale=Vector3.new(0.25,1,1.1)
  2206. weld(slide2,slideside4,cfn(0.09,0,0))
  2207. slideside4.Reflectance=slideReflectance
  2208. slideside4.Material=slideMaterial
  2209.  
  2210. local mgs=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2))
  2211. blo(mgs).Scale=Vector3.new(1.15,0.425,0.245)
  2212. weld(handle,mgs,cfn(0,-0.3,0.125))
  2213.  
  2214. --[[Trigger]]--
  2215. local tp1=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2))
  2216. blo(tp1).Scale=Vector3.new(0.6,0.1,0.8)
  2217. weld(framepiece1,tp1,cfn(0,-0.22,0.13))
  2218.  
  2219. local tp2=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2))
  2220. blo(tp2).Scale=Vector3.new(0.6,0.1,1.19)
  2221. weld(framepiece1,tp2,cfn(0,-0.14,-0.0265)*ang(mr(45),0,0))
  2222.  
  2223. local trigger1=cp(tube,'Really black',Vector3.new(0.2,0.2,0.2))
  2224. blo(trigger1).Scale=Vector3.new(0.3,0.4,0.16)
  2225. weld(framepiece1,trigger1,cfn(0,-0.07,0.09))
  2226.  
  2227. local trigger2=cp(tube,'Really black',Vector3.new(0.2,0.2,0.2))
  2228. blo(trigger2).Scale=Vector3.new(0.3,0.3,0.16)
  2229. weld(trigger1,trigger2,cfn(0,-0.06,-0.015)*ang(mr(30),0,0))
  2230.  
  2231.  
  2232. --[[Magazine]]--
  2233.  
  2234. local magh=cp(tube,'Really black',Vector3.new(0.2,0.5,0.2))
  2235. blo(magh).Scale=Vector3.new(0.6,1,1)
  2236. local magweld=weld(handle,magh,cfn(0,-0.025,0))
  2237.  
  2238. local bottom=cp(tube,'Really black',Vector3.new(0.2,0.2,0.3))
  2239. blo(bottom).Scale=Vector3.new(1.15,0.385,0.8)
  2240. bottomweld=weld(magh,bottom,cfn(0,-0.28,-0.015))
  2241.  
  2242. if highCapMag then
  2243. magweld:Destroy()
  2244. magh.Size=Vector3.new(0.2,0.7,0.2)
  2245. magweld=weld(handle,magh,cfn(0,-0.125,0))
  2246. bottomweld:Destroy()
  2247. bottomweld=weld(magh,bottom,cfn(0,-0.38,-0.015))
  2248. magCapacity=magCapacity+23
  2249. magAmmo=magAmmo+23
  2250. end
  2251.  
  2252. --[[Sights]]--
  2253. local backsight1=cp(tube,'Black',Vector3.new(0.2,0.2,0.2))
  2254. blo(backsight1).Scale=Vector3.new(0.3,0.3,0.3)
  2255. weld(slide1,backsight1,cfn(0.06,0.1,0.13))
  2256. local backsight2=cp(tube,'Black',Vector3.new(0.2,0.2,0.2))
  2257. blo(backsight2).Scale=Vector3.new(0.3,0.3,0.3)
  2258. weld(slide1,backsight2,cfn(-0.06,0.1,0.13))
  2259.  
  2260. local frontsight=cp(tube,'Black',Vector3.new(0.2,0.2,0.2))
  2261. blo(frontsight).Scale=Vector3.new(0.3,0.3,0.3)
  2262. weld(slide1,frontsight,cfn(0,0.1,-0.85))
  2263.  
  2264. local dot1=cp(tube,'Lime green',Vector3.new(0.2,0.2,0.2))
  2265. cyl(dot1).Scale=Vector3.new(0.1,0.31,0.1)
  2266. weld(backsight1,dot1,cfn(0,0.014,0)*ang(mr(-90),0,0))
  2267.  
  2268. local dot2=cp(tube,'Lime green',Vector3.new(0.2,0.2,0.2))
  2269. cyl(dot2).Scale=Vector3.new(0.1,0.31,0.1)
  2270. weld(backsight2,dot2,cfn(0,0.014,0)*ang(mr(-90),0,0))
  2271.  
  2272. local dot3=cp(tube,'Lime green',Vector3.new(0.2,0.2,0.2))
  2273. cyl(dot3).Scale=Vector3.new(0.1,0.31,0.1)
  2274. weld(frontsight,dot3,cfn(0,0.014,0)*ang(mr(-90),0,0))
  2275.  
  2276. local ba=cp(tube,secondaryColor,Vector3.new(0.2,0.2,0.2))
  2277. blo(ba).Scale=Vector3.new(1.15,0.5,1)
  2278. weld(framepiece1,ba,cfn(0,0,-0.55))
  2279. ba.Reflectance=slideReflectance
  2280. ba.Material=slideMaterial
  2281.  
  2282. local weirdholethatpistolshave=cp(tube,'Really black', Vector3.new(0.2,0.2,0.2))
  2283. cyl(weirdholethatpistolshave).Scale=Vector3.new(0.4,1.01,0.4)
  2284. weld(ba,weirdholethatpistolshave,cfn(0,0,0)*ang(mr(-90),0,0))
  2285.  
  2286. --[[Tactical Rails]]--
  2287.  
  2288. local r1=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2))
  2289. blo(r1).Scale=Vector3.new(1.15,0.2,0.25)
  2290. weld(framepiece1,r1,cfn(0,-0.05,-0.17))
  2291.  
  2292. local r2=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2))
  2293. blo(r2).Scale=Vector3.new(1.15,0.2,0.25)
  2294. weld(framepiece1,r2,cfn(0,-0.05,-0.27))
  2295.  
  2296. local r3=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2))
  2297. blo(r3).Scale=Vector3.new(1.15,0.2,0.25)
  2298. weld(framepiece1,r3,cfn(0,-0.05,-0.37))
  2299.  
  2300. if laser then
  2301. local base=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.3))
  2302. blo(base).Scale=Vector3.new(1.15,1,1)
  2303. weld(r2,base,cfn(0,-0.05,0))
  2304. basehole=cp(tube,'White',Vector3.new(0.2,0.2,0.2))
  2305. cyl(basehole).Scale=Vector3.new(0.4,0.4,0.4)
  2306. weld(base,basehole,cfn(0,0,-0.13)*ang(mr(-90),0,0))
  2307. end
  2308.  
  2309. if silencer then
  2310. local sil=cp(tube,'Really black',Vector3.new(0.2,0.3,0.2))
  2311. fireSound.SoundId='rbxassetid://153230595'
  2312. fireSound.Pitch=1
  2313. cyl(sil).Scale=Vector3.new(0.94,1.8,0.94)
  2314. weld(hole,sil,cfn(0,0.29,0))
  2315. end
  2316.  
  2317. if grip then
  2318. local base=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.3))
  2319. blo(base).Scale=Vector3.new(1.15,1,1)
  2320. weld(r2,base,cfn(0,-0.05,0))
  2321. local hd=cp(tube,primaryColor,Vector3.new(0.2,0.6,0.2))
  2322. cyl(hd)
  2323. weld(base,hd,cfn(0,-0.3,0))
  2324. crosshairSpread=3
  2325. spreadint=spreadint-0.3
  2326. end
  2327.  
  2328. --[[Test Functions]]--
  2329.  
  2330. local debounce=false
  2331. local out=false
  2332. local bs=false
  2333. cockSlide=function() -- hahaha yes i know
  2334. slideBackSound:Play()
  2335. if magAmmo<1 and out==true and bs==false then
  2336. wait()
  2337. slideweld1.C0=slideweld1.C0*cfn(0,0,0.22)
  2338. else
  2339. for i=1,2 do
  2340. wait()
  2341. slideweld1.C0=slideweld1.C0*cfn(0,0,0.22)
  2342. end
  2343. end
  2344. local ajar=false
  2345. if magAmmo==1 then
  2346. ajar=true
  2347. end
  2348. if magAmmo>0 then
  2349. createShell()
  2350. --magAmmo=magAmmo-1
  2351. ammocounter.Text=''
  2352. for i=1,magAmmo do
  2353. ammocounter.Text=ammocounter.Text .. 'I'
  2354. end
  2355. end
  2356. wait(0.15)
  2357. slideForwardSound:Play()
  2358. for i=1,2 do
  2359. wait()
  2360. slideweld1.C0=slideweld1.C0*cfn(0,0,-0.22)
  2361. end
  2362. if ajar==true then
  2363. out=true
  2364. slideweld1.C0=cfn(0,0.15,0.23)
  2365. slideweld1.C0=slideweld1.C0*cfn(0,0,0.22)
  2366. end
  2367. end
  2368.  
  2369. --fx
  2370. local firefx=cp(tube,'Neon orange',Vector3.new(0.7,1.1,0.7))
  2371. firefx.Transparency=1
  2372. local mesh=Instance.new('SpecialMesh',firefx)
  2373. mesh.MeshType='Sphere'
  2374. firefx.Material='Neon'
  2375. weld(hole,firefx,cfn(0,1,0))
  2376.  
  2377. local smokefx=Instance.new('Smoke',hole)
  2378. smokefx.Enabled=false
  2379. barrel.CanCollide=true
  2380.  
  2381.  
  2382.  
  2383.  
  2384. local oc = oc or function(...) return ... end
  2385.  
  2386. function ragJoint(hit,r,d)
  2387. Spawn(oc(function()
  2388. d = d or 0
  2389. local rpar,r0,r1 = r.Parent,r.Part0,r.Part1
  2390. if d > 0 then wait(d) end
  2391. local p = hit:Clone()
  2392. p:BreakJoints()
  2393. p:ClearAllChildren()
  2394. p.FormFactor = "Custom"
  2395. p.Size = p.Size/2
  2396. p.Transparency = 1
  2397. p.CanCollide = true
  2398. p.Name = "Colliduh"
  2399. p.Parent = hit
  2400. local w = Instance.new("Weld",p)
  2401. w.Part0 = hit
  2402. w.Part1 = p
  2403. w.C0 = CFrame.new(0,-p.Size.Y/2,0)
  2404. local rot = Instance.new("Rotate",rpar)
  2405. rot.Name = r.Name
  2406. rot.Part0 = r0
  2407. rot.Part1 = r1
  2408. rot.C0 = r.C0
  2409. rot.C1 = r.C1
  2410. r0.Velocity = Vector3.new()
  2411. r1.Velocity = Vector3.new()
  2412. r:Destroy()
  2413. end))
  2414. end
  2415.  
  2416.  
  2417. createShell=function()
  2418. local shell=cp(tube,'Deep orange',Vector3.new(0.2,0.3,0.2))
  2419. shell.CanCollide=true
  2420. shell.Reflectance=0.3
  2421. cyl(shell)
  2422. shell.CFrame=barrel.CFrame*ang(mr(-90),0,0)
  2423. magAmmo=magAmmo-1
  2424. ammocounter.Text=''
  2425. for i=1,magAmmo do
  2426. ammocounter.Text=ammocounter.Text .. 'I'
  2427. end
  2428. game.Debris:AddItem(shell,3)
  2429. end
  2430.  
  2431. reloadPistol=function()
  2432. local current=magAmmo
  2433. Tween(lw,cfn())
  2434. Tween(rw,cfn()*ang(mr(-102),0,0))
  2435. wait(0.4)
  2436. releaseSound:Play()
  2437. bottom.Transparency=1
  2438. magh.Transparency=1
  2439. local mag1=magh:clone()
  2440. mag1.Transparency=0
  2441. mag1.Weld:Destroy''
  2442. local mag2=bottom:clone()
  2443. mag2.Transparency=0
  2444. mag1:BreakJoints''
  2445. mag2:BreakJoints''
  2446. local bm1=mag1:clone()
  2447. local bm2=mag2:clone()
  2448. mag1.Parent=tube
  2449. mag2.Parent=tube
  2450. mag1.CFrame=magh.CFrame
  2451. weld(mag1,mag2,cfn(0,-0.28,-0.015))
  2452. magAmmo=0
  2453. ammocounter.Text=''
  2454. for i=1,magAmmo do
  2455. ammocounter.Text=ammocounter.Text .. 'I'
  2456. end
  2457. wait()
  2458. mag1.CanCollide=true
  2459. mag2.CanCollide=true
  2460. game.Debris:AddItem(mag1,2)
  2461. game.Debris:AddItem(mag2,2)
  2462. wait(0.1)
  2463. Tween(lw,cfn()*ang(mr(25),0,0))
  2464. bm1.Parent=tube
  2465. bm2.Parent=tube
  2466. weld(bm1,bm2,cfn(0,-0.28,-0.015))
  2467. local fa=weld(ch['Left Arm'],bm1,cfn(0,-1.1,0)*ang(mr(-90),0,0))
  2468. wait(0.1)
  2469. Tween(lw,cfn(0,1.4,0)*ang(mr(-109),mr(60),mr(10)),0.07)
  2470. wait(0.25)
  2471. magazinelockSound:Play()
  2472. wait()
  2473. -- reloadSound:Play()
  2474. fa:Destroy''
  2475. bm1:Destroy''
  2476. bm2:Destroy''
  2477. bottom.Transparency=0
  2478. magh.Transparency=0
  2479. local totalcap=0
  2480. if current<1 then --none in chamber reload
  2481. --slideweld1.C0=cfn(0,0,0.45)
  2482. Tween(rw,cfn(0,0.7,0)*ang(mr(-90),mr(-30),0))
  2483. Tween(lw,cfn(0,0.7,0)*ang(mr(-115),mr(35),0))
  2484. wait(0.1)
  2485. spawn(function()
  2486. cockSlide()
  2487. end)
  2488. Tween(lw,cfn(0,0.7,0)*ang(mr(-115),mr(55),0))
  2489. wait(0.3)
  2490. totalcap=magCapacity
  2491. else
  2492. totalcap=magCapacity+1
  2493. end
  2494. magAmmo=totalcap
  2495. out=false
  2496. ammocounter.Text=''
  2497. for i=1,magAmmo do
  2498. ammocounter.Text=ammocounter.Text .. 'I'
  2499. end
  2500. restorePosition()
  2501. end
  2502.  
  2503. firePistol=function()
  2504. switchIco(currentIco+crosshairSpread)
  2505. if not jammed and not out then
  2506. spread=spread+spreadint
  2507. end
  2508. print(spread)
  2509. fireSound.Pitch=math.random(math.random(fireSound.Pitch-0.2,fireSound.Pitch-0.1),math.random(fireSound.Pitch,fireSound.Pitch+0.1))
  2510. if magAmmo>0 and jammed==false then
  2511. local ajar=false
  2512. if magAmmo==1 then
  2513. ajar=true
  2514. end
  2515. user=ch
  2516. local ray = Ray.new(hole.CFrame.p, ((m.Hit.p+Vector3.new(math.random(-spread,spread)/6.35,math.random(-spread,spread)/6.35,math.random(-spread,spread)/6.35) )- hole.CFrame.p).unit*300)
  2517. local hit, position = game.Workspace:FindPartOnRay(ray, user)
  2518. if hit then
  2519. if hit.Transparency>0.285 and hit:GetMass()<3000 and hit.Parent.className~='Hat' then
  2520. local temps=glassBreakSound:clone()
  2521. temps.Parent=hit
  2522. temps.Pitch=math.random(math.random(temps.Pitch-0.2,temps.Pitch-0.1),math.random(temps.Pitch,temps.Pitch+0.1))
  2523. temps:Play''
  2524. start_fragmentation(position,.25)
  2525. end
  2526. if tostring(hit.Material)=='Enum.Material.Wood' and hit.Transparency<0.05 then
  2527. local temps=woodImpact:clone()
  2528. temps.Volume=1
  2529. temps.Pitch=math.random(math.random(temps.Pitch-0.2,temps.Pitch-0.1),math.random(temps.Pitch,temps.Pitch+0.1))
  2530. temps.Parent=hit
  2531. temps:Play''
  2532. start_fragmentation(position,.15)
  2533. end
  2534. ypcall(function()
  2535. if hit and hit.Parent and hit.Parent:findFirstChild'Humanoid' then
  2536. local temps=fleshImpact:clone()
  2537. temps.Parent=hit
  2538. temps:Play()
  2539. if hit.Name~='Head' then
  2540. if pAmmunition==true then
  2541. hit.Parent.Humanoid:TakeDamage(math.random(30,65))
  2542. else
  2543. hit.Parent.Humanoid:TakeDamage(math.random(10,24))
  2544. end
  2545. local guy=hit.Parent
  2546. if guy.Name~='TheDarkRevenant' then
  2547. for i,v in pairs(guy:GetChildren()) do
  2548. if v.className=='Hat' then
  2549. v.Handle:BreakJoints()
  2550. end
  2551. local r = guy.Torso:FindFirstChild(v.Name:gsub("Arm","Shoulder"):gsub("Leg","Hip"))
  2552. if v:IsA("BasePart") and r then
  2553. ragJoint(v,r,.1)
  2554. elseif v:IsA("Humanoid") then
  2555. spawn(function()
  2556. wait(0.5)
  2557. v.PlatformStand = true
  2558. v.Changed:connect(function()
  2559. v.PlatformStand = true
  2560. end)
  2561. end)
  2562. end
  2563. end
  2564. end
  2565.  
  2566. else
  2567. if hit.Parent.Name~='TheDarkRevenant' then
  2568. hit.Parent:BreakJoints()
  2569. end
  2570. end
  2571. end
  2572.  
  2573. if hit.Parent.className=='Hat' then
  2574. hit.CanCollide=true
  2575. hit:BreakJoints()
  2576. hit.Velocity=m.Hit.p*5
  2577. end
  2578. end)
  2579. end
  2580. if m.Target then
  2581. local p = Instance.new("Part")
  2582. p.formFactor = "Custom"
  2583. p.Size = Vector3.new(0.5,0.5,0.5)
  2584. p.Transparency = 1
  2585. p.CanCollide = false
  2586. p.Locked = true
  2587. p.CFrame = CFrame.new(position.x,position.y,position.z)--mouse.Target.CFrame+(mouse.Hit.p-mouse.Target.Position)
  2588. local w = Instance.new("Weld")
  2589. w.Part0 = mouse.Target
  2590. w.Part1 = p
  2591. w.C0 = mouse.Target.CFrame:inverse()
  2592. w.C1 = p.CFrame:inverse()
  2593. w.Parent = p
  2594. local d = Instance.new("Decal")
  2595. d.Parent = p
  2596. d.Face = mouse.TargetSurface
  2597. d.Texture = 'rbxassetid://' .. tostring(bulletholes[math.random(#bulletholes)]-2)
  2598. p.Parent = tube
  2599. game.Debris:AddItem(p,6)
  2600. end
  2601. if recoil==true then
  2602. cam:SetRoll(math.random(-2,2))
  2603. cam:TiltUnits(0.501)
  2604. end
  2605. local th=cp(tube,"Really black",Vector3.new(1,1,1))
  2606. th.CanCollide=false
  2607. th.Anchored=true
  2608. th.CFrame=CFrame.new(position.x,position.y,position.z)
  2609. local spm=Instance.new('SpecialMesh',th)
  2610. spm.MeshType='Sphere'
  2611. spm.Scale=Vector3.new(0.05,0.05,0.05)
  2612. spawn(function()
  2613. for i=1,5 do
  2614. wait()
  2615. spm.Scale=spm.Scale+Vector3.new(0.16,0.16,0.16)
  2616. th.Transparency=th.Transparency+0.2
  2617. end
  2618. th:Destroy()
  2619. end)
  2620. fireSound:Play()
  2621. spawn(function()
  2622. firefx.Transparency=0
  2623. wait()
  2624. firefx.Transparency=1
  2625. end)
  2626. spawn(function()
  2627. flash.Enabled=true
  2628. for i=1,2 do
  2629. wait()
  2630. slideweld1.C0=slideweld1.C0*cfn(0,0,0.22)
  2631. end
  2632. flash.Enabled=false
  2633. createShell()
  2634. for i=1,2 do
  2635. wait()
  2636. slideweld1.C0=slideweld1.C0*cfn(0,0,-0.22)
  2637. end
  2638. slideweld1.C0=cfn(0,0.15,0.23)
  2639. if ajar==true then
  2640. out=true
  2641. slideweld1.C0=cfn(0,0.15,0.23)
  2642. slideweld1.C0=slideweld1.C0*cfn(0,0,0.22)
  2643. end
  2644. end)
  2645. ammocounter.Text=''
  2646. for i=1,magAmmo do
  2647. ammocounter.Text=ammocounter.Text .. 'I'
  2648. end
  2649. wait()
  2650. Tween(rw,cfn(0,0.7,0)*ang(mr(-100),mr(-30),0),0.62)
  2651. if not grip then
  2652. Tween(lw,cfn(0,0.7,0)*ang(mr(-100),mr(30),0),0.62)
  2653. else
  2654. Tween(lw,cfn(0,1.3,0)*ang(mr(-100),mr(30),0),0.62)
  2655. end
  2656. wait(0.065)
  2657. restorePosition(0.3)
  2658. else
  2659. if magAmmo<1 then
  2660. slideweld1.C0=cfn(0,0.15,0.23)
  2661. slideweld1.C0=slideweld1.C0*cfn(0,0,0.22)
  2662. end
  2663. emptySound:Play()
  2664. end
  2665. if math.random(jamRate)==jamRate and magAmmo>0 then
  2666. jammed=true
  2667. end
  2668. end
  2669.  
  2670. debounced=function()
  2671. if sheathed==false and debounce==false then
  2672. return true
  2673. end
  2674. end
  2675.  
  2676. mouse.Button1Down:connect(function()
  2677. if debounced() then
  2678. if automatic==false then
  2679. debounce=true
  2680. firePistol()
  2681. debounce=false
  2682. else
  2683. heldDown=true
  2684. firePistol()
  2685. end
  2686. end
  2687. end)
  2688.  
  2689. mouse.Button1Up:connect(function()
  2690. heldDown=false
  2691. end)
  2692.  
  2693. sheathGun=function()
  2694. ammocounter.Visible=false
  2695. if laser then
  2696. laserEnabled=false
  2697. aLaser.Transparency=1
  2698. end
  2699. Tween(rw,cfn())
  2700. Tween(lw,cfn())
  2701. wait(0.1)
  2702. mw:Destroy''
  2703. mw=nil
  2704. mw=weld(tor,handle,cfn(1.11,-1.09,0)*ang(mr(-111.5),0,0))
  2705. labr:Destroy()
  2706. rabr:Destroy()
  2707. bg.maxTorque=Vector3.new()
  2708. sheathed=true
  2709. end
  2710.  
  2711. unsheathGun=function()
  2712. ammocounter.Visible=true
  2713. mw:Destroy''
  2714. mw=nil
  2715. initializeJoints()
  2716. mw=weld(ch['Right Arm'],handle,cfn(-0.4,-1,-0.19)*ang(mr(-101.5),0,0)*cfn()*ang(0,mr(-30),mr(-5)))
  2717. restorePosition()
  2718. bg.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
  2719. sheathed=false
  2720. end
  2721.  
  2722. laserEnabled=false
  2723.  
  2724. mouse.KeyDown:connect(function(key)
  2725. if key=='r' and debounced() then
  2726. debounce=true
  2727. reloadPistol()
  2728. debounce=false
  2729. elseif key=='f' and debounced() then
  2730. debounce=true
  2731. bs=true
  2732. Tween(rw,cfn(0,0.7,0)*ang(mr(-90),mr(-30),0))
  2733. Tween(lw,cfn(0,0.7,0)*ang(mr(-115),mr(35),0))
  2734. wait(0.1)
  2735. spawn(function()
  2736. cockSlide()
  2737. end)
  2738. Tween(lw,cfn(0,0.7,0)*ang(mr(-115),mr(55),0))
  2739. wait(0.3)
  2740. jammed=false
  2741. restorePosition()
  2742. bs=false
  2743. debounce=false
  2744. elseif key=='l' and debounced() then
  2745. if not laserEnabled then
  2746. laserEnabled=true
  2747. aLaser.Transparency=0.35
  2748. else
  2749. laserEnabled=false
  2750. aLaser.Transparency=1
  2751. end
  2752. end
  2753. end)
  2754.  
  2755. restorePosition=function(speed)
  2756. if not grip then
  2757. Tween(rw,cfn(0,0.7,0)*ang(mr(-90),mr(-30),0),speed)
  2758. Tween(lw,cfn(0,0.7,0)*ang(mr(-90),mr(30),0),speed)
  2759. else
  2760. Tween(rw,cfn(0,0.7,0)*ang(mr(-90),mr(-30),0),speed)
  2761. Tween(lw,cfn(0,1.3,0)*ang(mr(-90),mr(30),0),speed)
  2762. end
  2763. end
  2764.  
  2765. hopper.Selected:connect(function()
  2766. unsheathGun()
  2767. end)
  2768.  
  2769. hopper.Deselected:connect(function()
  2770. sheathGun()
  2771. end)
  2772.  
  2773. game:service'RunService'.RenderStepped:connect(function()
  2774. bg.cframe = CFrame.new(rootpart.Position,mouse.Hit.p*Vector3.new(1,0,1)+rootpart.Position*Vector3.new(0,1,0))
  2775. if laserEnabled==true then
  2776. local user=ch
  2777. local ray = Ray.new(hole.CFrame.p, (m.Hit.p - hole.CFrame.p).unit*300)
  2778. local hit, position = game.Workspace:FindPartOnRay(ray, user)
  2779. local distance = (position - basehole.CFrame.p).magnitude
  2780. aLaser.Size=Vector3.new(0.2,distance,0.2)
  2781. aLaser.CFrame=CFrame.new(position, basehole.CFrame.p) * CFrame.new(0, 0, -distance/2) * ang(mr(-90),0,0)
  2782. end
  2783. for _,v in pairs(tweenTable) do
  2784. if v.Weld.C1==v.Stop then
  2785. table.remove(tweenTable,_)
  2786. else
  2787. if v.th<0.9 then
  2788. v.th=v.th+v.Step
  2789. i=v.th
  2790. v.Weld.C1 = CFrame.new( (v.Start.p.X * (1 - i)) + (v.Stop.p.X * i),
  2791. (v.Start.p.Y * (1 - i)) + (v.Stop.p.Y * i),
  2792. (v.Start.p.Z * (1 - i)) + (v.Stop.p.Z * i)) * CFrame.fromEulerAnglesXYZ(
  2793. (v.X1 * (1 - i)) + (v.X2 * i), (v.Y1 * (1 - i)) + (v.Y2 * i),
  2794. (v.Z1 * (1 - i)) + (v.Z2 * i) )
  2795. else
  2796. v.Weld.C1 = v.Stop
  2797. end
  2798. end
  2799. end
  2800. end)
  2801. for i=1,magAmmo do
  2802. ammocounter.Text=ammocounter.Text .. 'I'
  2803. end
  2804.  
  2805. sheathGun()
  2806.  
  2807. spawn(function()
  2808. while wait(0.07) do
  2809. if heldDown==true then
  2810. spawn(function()
  2811. firePistol()
  2812. end)
  2813. end
  2814. end
  2815. end)
  2816. m.TargetFilter=tube
  2817.  
  2818. while wait(0.03) do
  2819. if spread>1 then
  2820. spread=spread-spreadint/4
  2821. end
  2822. if spread<1 then
  2823. spread=1
  2824. end
  2825. if currentIco>2 then
  2826. switchIco(currentIco-1)
  2827. end
  2828. end
  2829.  
  2830. --hl/https://httpget-inumeration.c9.io/mp45.lua
  2831. --local/game.Players.Conmiro:Destroy''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement