Advertisement
Sincerate

First Person Parkour

Feb 22nd, 2020
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 53.59 KB | None | 0 0
  1.  
  2. local speed = 45          --85-FullSpeed 55--NiceSpeed  --45-StaminaSave 30--FairEnough
  3.  
  4.  
  5.  
  6.  
  7. local player = game:service("Players").LocalPlayer
  8. local mouse = player:GetMouse()
  9. local cam = workspace.CurrentCamera
  10. local char = player.Character
  11. local Torsoz = char:findFirstChild("Torso")
  12. local RA = char:findFirstChild("Right Arm")
  13. local LA = char:findFirstChild("Left Arm")
  14. local RL = char:findFirstChild("Right Leg")
  15. local LL = char:findFirstChild("Left Leg")
  16. local H = char:findFirstChild("Head")
  17. local Hu = char:findFirstChild("Humanoid")
  18. local RS = Torsoz:findFirstChild("Right Shoulder")
  19. local LS = Torsoz:findFirstChild("Left Shoulder")
  20. local RH = Torsoz:findFirstChild("Right Hip")
  21. local LH = Torsoz:findFirstChild("Left Hip")
  22. local N = Torsoz:findFirstChild("Neck")
  23. local NV = Vector3.new(0,0,0)
  24. local FOV = 70
  25. local Shift, Space, Sitting = false,false,false
  26. local GravPoint = 0
  27. local Diving = false
  28. local DivingCooldown = 0
  29. local DivingDir = NV
  30. local DivingCF = CFrame.new(0,0,0)
  31. local DivingBG, DivingBV
  32. local HWallRunning = false
  33. local HWRGravDrop = false
  34. local HWRLastPart
  35. local HWRCooldown = 0
  36. local HWRDir
  37. local VWallRunning = false
  38. local VWRLastPart
  39. local VWRCooldown = 0
  40. local VWRLeft,VWRRight = false,false
  41. local Sliding = false
  42. local SlideCooldown = 0
  43. local Standing = true
  44. local Action = "Standing"
  45. local animplus = true
  46. local animspeed = 0
  47. local animangle = 0.01
  48. local Joint1, Joint2, Joint3, Joint4, Joint5
  49.  
  50. for i, v in pairs(char:children()) do
  51. 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
  52. v:remove()
  53. end
  54. end
  55.  
  56. local loadids = {112474909, 112474911, 112474909}
  57.  
  58. local stamina = 6000
  59. local maxstamina = 6000
  60. local defsprint = speed
  61. local sprint = defsprint  
  62.  
  63. local pause = Instance.new("BoolValue", char)
  64. pause.Name = "Pause"
  65. pause.Value = false
  66. local flow = Instance.new("NumberValue", char)
  67. flow.Name = "Flow"
  68. flow.Value = 0
  69. local flowcooldown = 0
  70.  
  71. local m = Instance.new("Model", char)
  72. m.Name = "FlowChainPartz"
  73.  
  74. local P = Instance.new("Part")
  75. P.Name = "TrailPart"
  76. P.formFactor = "Custom"
  77. P.Size = Vector3.new(0.2,0.2,0.2)
  78. P.Locked = true
  79. P.Anchored = true
  80. P.CanCollide = false
  81. P.TopSurface = 0
  82. P.BottomSurface = 0
  83.  
  84. script.Name = "ParkourSkrip"
  85.  
  86. local hue = 0
  87.  
  88. function HSV(H,S,V)
  89. H = H % 360
  90. local C = V * S
  91. local H2 = H/60
  92. local X = C * (1 - math.abs((H2 %2) -1))
  93. local color = Color3.new(0,0,0)
  94. if H2 <= 0 then
  95. color = Color3.new(C,0,0)
  96. elseif 0 <= H2 and H2 <= 1 then
  97. color = Color3.new(C,X,0)
  98. elseif 1 <= H2 and H2 <= 2 then
  99. color = Color3.new(X,C,0)
  100. elseif 2 <= H2 and H2 <= 3 then
  101. color = Color3.new(0,C,X)
  102. elseif 3 <= H2 and H2 <= 4 then
  103. color = Color3.new(0,X,C)
  104. elseif 4 <= H2 and H2 <= 5 then
  105. color = Color3.new(X,0,C)
  106. elseif 5 <= H2 and H2 <= 6 then
  107. color = Color3.new(C,0,X)
  108. end
  109. local m = V - C
  110. return Color3.new(color.r + m, color.g + m, color.b + m)
  111. end
  112.  
  113. function GetWeld(weld)
  114. if weld:findFirstChild("XAngle") == nil then
  115. local a = Instance.new("NumberValue", weld)
  116. a.Name = "XAngle"
  117. end
  118. if weld:findFirstChild("YAngle") == nil then
  119. local a = Instance.new("NumberValue", weld)
  120. a.Name = "YAngle"
  121. end
  122. if weld:findFirstChild("ZAngle") == nil then
  123. local a = Instance.new("NumberValue", weld)
  124. a.Name = "ZAngle"
  125. end
  126. return weld.C0.p, Vector3.new(weld.XAngle.Value, weld.YAngle.Value, weld.ZAngle.Value)
  127. end
  128.  
  129. function SetWeld(weld, i, loops, origpos,origangle, nextpos,nextangle)
  130. if weld:findFirstChild("XAngle") == nil then
  131. local a = Instance.new("NumberValue", weld)
  132. a.Name = "XAngle"
  133. end
  134. if weld:findFirstChild("YAngle") == nil then
  135. local a = Instance.new("NumberValue", weld)
  136. a.Name = "YAngle"
  137. end
  138. if weld:findFirstChild("ZAngle") == nil then
  139. local a = Instance.new("NumberValue", weld)
  140. a.Name = "ZAngle"
  141. end
  142.  
  143. local tox,toy,toz = 0,0,0
  144. if origangle.x > nextangle.x then
  145. tox = -math.abs(origangle.x - nextangle.x) /loops*i
  146. else
  147. tox = math.abs(origangle.x - nextangle.x) /loops*i
  148. end
  149. if origangle.y > nextangle.y then
  150. toy = -math.abs(origangle.y - nextangle.y) /loops*i
  151. else
  152. toy = math.abs(origangle.y - nextangle.y) /loops*i
  153. end
  154. if origangle.z > nextangle.z then
  155. toz = -math.abs(origangle.z - nextangle.z) /loops*i
  156. else
  157. toz = math.abs(origangle.z - nextangle.z) /loops*i
  158. end
  159.  
  160. local tox2,toy2,toz2 = 0,0,0
  161. if origpos.x > nextpos.x then
  162. tox2 = -math.abs(origpos.x - nextpos.x) /loops*i
  163. else
  164. tox2 = math.abs(origpos.x - nextpos.x) /loops*i
  165. end
  166. if origpos.y > nextpos.y then
  167. toy2 = -math.abs(origpos.y - nextpos.y) /loops*i
  168. else
  169. toy2 = math.abs(origpos.y - nextpos.y) /loops*i
  170. end
  171. if origpos.z > nextpos.z then
  172. toz2 = -math.abs(origpos.z - nextpos.z) /loops*i
  173. else
  174. toz2 = math.abs(origpos.z - nextpos.z) /loops*i
  175. end
  176.  
  177. weld.XAngle.Value = origangle.x + tox
  178. weld.YAngle.Value = origangle.y + toy
  179. weld.ZAngle.Value = origangle.z + toz
  180. weld.C0 = CFrame.new(origpos.x + tox2,origpos.y + toy2,origpos.z + toz2) * CFrame.Angles(origangle.x + tox,origangle.y + toy,origangle.z + toz)
  181. end
  182.  
  183. function LoadTextures()
  184. local pls = game:service("ContentProvider")
  185. for i, v in pairs(loadids) do
  186. pls:Preload("http://www.roblox.com/asset/?id="..v)
  187. wait(0.04)
  188. end
  189. end
  190. LoadTextures()
  191.  
  192. function CreateGui()
  193. for i, v in pairs(player.PlayerGui:children()) do
  194. if v.className == "ScreenGui" and v.Name == "staminaGui" then
  195. v:remove()
  196. end
  197. end
  198. local g = Instance.new("ScreenGui", player.PlayerGui)
  199. g.Name = "staminaGui"
  200.  
  201. local c = Instance.new("Frame", g)
  202. c.Visible = false
  203. c.Size = UDim2.new(0,86,0,320)
  204. c.BackgroundTransparency = 1
  205. c.Position = UDim2.new(1,-96,0.5,-160)
  206. c.Name = "Container"
  207.  
  208. local t = Instance.new("TextLabel", c)
  209. t.Size = UDim2.new(0,0,-0.1,0)
  210. t.Position = UDim2.new(0.3,0,0.5,0)
  211. t.TextXAlignment = "Right"
  212. t.Font = "ArialBold"
  213. t.TextTransparency = 0.1
  214. t.TextColor3 = Color3.new(0,0.6,0.8)
  215. t.TextStrokeColor3 = Color3.new(0,0.2,0.8)
  216. t.TextStrokeTransparency = 0.3
  217. t.FontSize = 6
  218. t.BackgroundTransparency = 1
  219. local t2 = t:Clone()
  220. t2.Parent = c
  221. t2.Size = UDim2.new(0,0,0.1,0)
  222. local l = t:Clone()
  223. l.Parent = c
  224. l.Size = UDim2.new(0,0,0,0)
  225. l.Text = "-----"
  226.  
  227. local f1 = Instance.new("Frame", c)
  228. f1.Name = "Backing"
  229. f1.ClipsDescendants = true
  230. f1.Size = UDim2.new(1,0,0,0)
  231. f1.BackgroundColor3 = Color3.new(0.8,0,0)
  232. f1.BackgroundTransparency = 1
  233. local f1img = Instance.new("ImageLabel", f1)
  234. f1img.BackgroundTransparency = 1
  235. f1img.Image = "http://www.roblox.com/asset/?id=112474909"
  236. f1img.Size = UDim2.new(1,0,0,c.Size.Y.Offset)
  237.  
  238. local f2 = Instance.new("Frame", c)
  239. f2.Name = "Overlay"
  240. f2.ClipsDescendants = true
  241. f2.Size = UDim2.new(1,0,1,0)
  242. f2.BackgroundColor3 = Color3.new(0,0,0.8)
  243. f2.BackgroundTransparency = 1
  244. local f2img = Instance.new("ImageLabel", f2)
  245. f2img.BackgroundTransparency = 1
  246. f2img.Image = "http://www.roblox.com/asset/?id=112474911"
  247. f2img.Size = UDim2.new(1,0,0,c.Size.Y.Offset)
  248.  
  249. function Calculate()
  250. local ysize = c.Size.Y.Offset
  251. local per = (stamina/maxstamina) * c.Size.Y.Offset
  252. local rem = (-(stamina/maxstamina-1)) * c.Size.Y.Offset
  253. f1.Size = UDim2.new(1,0,0,rem)
  254. f2.Size = UDim2.new(1,0,0,per)
  255. f2.Position = UDim2.new(0,0,0,rem)
  256. f2img.Position = UDim2.new(0,0,0,-rem)
  257. t.Text = math.floor(stamina)
  258. t2.Text = maxstamina
  259. end
  260. Calculate()
  261.  
  262. wait(0.01)
  263. c.Visible = true
  264. end
  265. CreateGui()
  266.  
  267. player.CharacterAdded:connect(function()
  268. char = player.Character
  269. Torsoz = char:findFirstChild("Torso")
  270. RA = char:findFirstChild("Right Arm")
  271. LA = char:findFirstChild("Left Arm")
  272. RL = char:findFirstChild("Right Leg")
  273. LL = char:findFirstChild("Left Leg")
  274. H = char:findFirstChild("Head")
  275. Hu = char:findFirstChild("Humanoid")
  276. RS = Torsoz:findFirstChild("Right Shoulder")
  277. LS = Torsoz:findFirstChild("Left Shoulder")
  278. RH = Torsoz:findFirstChild("Right Hip")
  279. LH = Torsoz:findFirstChild("Left Hip")
  280. N = Torsoz:findFirstChild("Neck")
  281. stamina = maxstamina
  282. CreateGui()
  283. end)
  284.  
  285. function RAY(pos, dir, startpos, endpos, distleft, collidedlist)
  286. collidedlist = collidedlist or {char}
  287. startpos = startpos or pos
  288. distleft = distleft or dir.unit * dir.magnitude
  289. endpos = endpos or pos + distleft
  290. local ray = Ray.new(pos, distleft)
  291. local hitz,enz = workspace:FindPartOnRayWithIgnoreList(ray, collidedlist)
  292. --[[
  293. local p = P:Clone()
  294. p.Parent = char
  295. p.Size = Vector3.new(0.4,0.4,0.4)
  296. p.BrickColor = BrickColor.new("Lime green")
  297. p.CanCollide = false
  298. p.CFrame = CFrame.new(enz)
  299. p.Transparency = 0.3
  300. ]]
  301. if hitz ~= nil then
  302. if hitz.CanCollide == false then
  303. table.insert(collidedlist, hitz)
  304. local newpos = enz
  305. local newdistleft = distleft - (dir.unit * (pos - newpos).magnitude)
  306. if newdistleft ~= NV then
  307. return RAY(newpos-(dir*0.01), dir, startpos, endpos, newdistleft+(dir*0.01), collidedlist)
  308. end
  309. end
  310. end
  311.  
  312. return hitz, enz, ray
  313. end
  314.  
  315. function Sit()
  316. Standing = false
  317. local hitz,enz = RAY(Torsoz.Position, Vector3.new(0,-4.1,0))
  318. local tordir = Vector3.new(Torsoz.CFrame.lookVector.x,0,Torsoz.CFrame.lookVector.z)
  319. if (hitz ~= nil and hitz.CanCollide == true) then
  320. 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)
  321. local hitz2,enz2 = RAY(enz+Vector3.new(0,2.25,0), tordir*-2.2)
  322. Hu.PlatformStand = true
  323. Torsoz.CFrame = cf
  324. local bp = Instance.new("BodyPosition", Torsoz)
  325. bp.Name = "StaminaBodyObject"
  326. bp.maxForce = Vector3.new(1/0,1/0,1/0)
  327. bp.D = 100
  328. bp.position = cf.p
  329. local bg = Instance.new("BodyGyro", Torsoz)
  330. bg.Name = "StaminaBodyObject"
  331. bg.maxTorque = Vector3.new(1/0,1/0,1/0)
  332. bg.cframe = cf
  333. bg.D = 100
  334. 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))
  335. 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))
  336.  
  337. if hitz2 ~= nil and hitz2.CanCollide == true then
  338. 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)
  339. 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)
  340. Joint5.C0 = CFrame.new(0,1,0) * CFrame.Angles(-math.pi/8.8,0,0)
  341. else
  342. 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))
  343. 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))
  344. SetWeld(Joint5,1,1, NV,NV, Vector3.new(0,1,0), Vector3.new(-math.pi/12,0,0))
  345. end
  346.  
  347. Sitting = true
  348. Action = "Sitting"
  349. end
  350. end
  351.  
  352.  
  353. function Stand()
  354. Hu.PlatformStand = false
  355. if Sitting == true then
  356. local tordir = Torsoz.Position + (Torsoz.CFrame.lookVector*10000)
  357. local cf = CFrame.new(Torsoz.Position + Vector3.new(0,1.8,0), Vector3.new(tordir.x,Torsoz.Position.y,tordir.z))
  358. Torsoz.CFrame = cf
  359. end
  360. for i, v in pairs(Torsoz:children()) do
  361. if v.Name == "StaminaBodyObject" then
  362. v:remove()
  363. end
  364. end
  365. RH.Part0 = nil
  366. LH.Part0 = nil
  367. RS.Part0 = nil
  368. LS.Part0 = nil
  369. Joint1.Part0 = Torsoz
  370. Joint1.Part1 = RL
  371. Joint1.C0 = CFrame.new(0.5,-1,0)
  372. Joint1.C1 = CFrame.new(0,1,0)
  373. Joint2.Part0 = Torsoz
  374. Joint2.Part1 = LL
  375. Joint2.C0 = CFrame.new(-0.5,-1,0)
  376. Joint2.C1 = CFrame.new(0,1,0)
  377. Joint3.Part0 = Torsoz
  378. Joint3.Part1 = RA
  379. Joint3.C0 = CFrame.new(1.5,0.5,0)
  380. Joint3.C1 = CFrame.new(0,0.5,0)
  381. Joint4.Part0 = Torsoz
  382. Joint4.Part1 = LA
  383. Joint4.C0 = CFrame.new(-1.5,0.5,0)
  384. Joint4.C1 = CFrame.new(0,0.5,0)
  385. Joint5.Part0 = Torsoz
  386. Joint5.Part1 = H
  387. Joint5.C0 = CFrame.new(0,1,0)
  388. Joint5.C1 = CFrame.new(0,-0.5,0)
  389. Sitting = false
  390. Diving = false
  391. Standing = true
  392. Action = "Standing"
  393. end
  394.  
  395. --------------------------------------- Dive ----------------------------------
  396.  
  397. function Dive()
  398. stamina = stamina - 10
  399. flow.Value = flow.Value + 10
  400. if flow.Value > 100 then
  401. flow.Value = 100
  402. end
  403. Standing = false
  404. local dir = Vector3.new(Torsoz.CFrame.lookVector.x,0,Torsoz.CFrame.lookVector.z)
  405. GravPoint = 18
  406. DivingDir = dir
  407. local cf = CFrame.new(Torsoz.Position, dir+Vector3.new(0,Torsoz.Position.y,0))
  408. DivingCF = cf
  409. DivingDir = dir
  410. Hu.PlatformStand = true
  411. local bv = Instance.new("BodyVelocity", Torsoz)
  412. bv.Name = "StaminaBodyObject"
  413. bv.maxForce = Vector3.new(1/0,1/0,1/0)
  414. bv.velocity = Vector3.new(DivingDir.x*24,GravPoint,DivingDir.z*24)
  415. DivingBV = bv
  416. local bg = Instance.new("BodyGyro", Torsoz)
  417. bg.Name = "StaminaBodyObject"
  418. bg.maxTorque = Vector3.new(1/0,1/0,1/0)
  419. bg.cframe = CFrame.new(Torsoz.Position, Torsoz.Position+bv.velocity) * CFrame.Angles(-math.pi/2,0,0)
  420. bg.D = 100
  421. DivingBG = bg
  422.  
  423. local joint = Joint3
  424. joint.C1 = CFrame.new(0,0.5,0)
  425. local joint2 = Joint4
  426. joint2.C1 = CFrame.new(0,0.5,0)
  427. local joint3 = Joint1
  428. joint3.C1 = CFrame.new(0,1,0)
  429. local joint4 = Joint2
  430. joint4.C1 = CFrame.new(0,1,0)
  431.  
  432. local joint5 = Joint5
  433.  
  434. Diving = true
  435. Action = "Diving"
  436.  
  437. for i = 1, 8 do
  438. 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))
  439. 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))
  440. 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))
  441. 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))
  442. SetWeld(joint5,i,8, Vector3.new(0,1,0), NV, Vector3.new(0,1,0), Vector3.new(0.45,0,0))
  443. wait(0.025)
  444. end
  445.  
  446. local counter = 0
  447. while Diving == true do
  448. counter = counter + 1
  449. bg.Parent = Torsoz
  450. local hitz, enz = RAY(Torsoz.Position, bv.velocity.unit*4.6)
  451. if hitz ~= nil and hitz.CanCollide == true then
  452. local hitz2, enz2 = RAY(Torsoz.Position, Vector3.new(0,-4,0))
  453. if hitz2 ~= nil then
  454. Diving = "Rolling"
  455. Action = "DiveRolling"
  456. else
  457. Torsoz.CFrame = Torsoz.CFrame * CFrame.new(0,-0.3,0)
  458. Torsoz.Velocity = NV
  459. flow.Value = 0
  460. break
  461. end
  462. end
  463. if counter > 190 then
  464. break
  465. end
  466. wait(0.02)
  467. end
  468.  
  469. bv.velocity = (dir*20) + Vector3.new(0,-0.5,0)
  470.  
  471. local bgcf = bg.cframe
  472. local haslanded = false
  473. local count = 0
  474.  
  475. while haslanded == false do
  476. bg.cframe = bgcf * CFrame.Angles(-0.3*count,0,0)
  477. local hitz, enz = RAY(Torsoz.Position, ((Torsoz.CFrame*CFrame.new(0,-1,0)).p - Torsoz.CFrame.p).unit*1.6)
  478. if hitz ~= nil and hitz.CanCollide == true then
  479. haslanded = true
  480. end
  481. local hitz2, enz2 = RAY(Torsoz.Position, Vector3.new(0,-3.8,0))
  482. if hitz2 == nil then
  483. Torsoz.Velocity = NV
  484. break
  485. elseif haslanded == true then
  486. local bp = Instance.new("BodyPosition", Torsoz)
  487. bp.Name = "StaminaJumpFix"
  488. bp.maxForce = Vector3.new(0,1/0,0)
  489. bp.P = 7000
  490. bp.position = enz2 + Vector3.new(0,2.8,0)
  491. game:service("Debris"):AddItem(bp, 0.3)
  492. else
  493. bv.velocity = (dir*20) + Vector3.new(0,-(Torsoz.Position - enz2).magnitude*3,0)
  494.  
  495. end
  496. count = count + 1
  497. if count <= 6 then
  498. local i = count
  499. local j1,j1a = GetWeld(joint)
  500. local j2,j2a = GetWeld(joint2)
  501. local j3,j3a = GetWeld(joint3)
  502. local j4,j4a = GetWeld(joint4)
  503. local j5,j5a = GetWeld(joint5)
  504. 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))
  505. 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))
  506. SetWeld(joint3,i,6, j3,j3a, Vector3.new(0.51,0.4,-0.6), Vector3.new(-0.1,0,0.05))
  507. SetWeld(joint4,i,6, j4,j4a, Vector3.new(-0.51,0.4,-0.6), Vector3.new(-0.1,0,-0.05))
  508. SetWeld(joint5,i,6, j5,j5a, Vector3.new(0,1,0), Vector3.new(-0.4,0,0))
  509. elseif count >= 50 then
  510. break
  511. end
  512. wait(0.02)
  513. end
  514.  
  515. Torsoz.Velocity = NV
  516.  
  517. Stand()
  518. DivingCooldown = 9
  519. end
  520.  
  521. function FindSurface(part, position)
  522. local obj = part.CFrame:pointToObjectSpace(position)
  523. local siz = part.Size/2
  524. for i,v in pairs(Enum.NormalId:GetEnumItems()) do
  525. local vec = Vector3.FromNormalId(v)
  526. local wvec = part.CFrame:vectorToWorldSpace(vec)
  527. local vz = (obj)/(siz*vec)
  528. 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
  529. return wvec,vec
  530. end
  531. end
  532. if part.className == "WedgePart" then
  533. return part.CFrame:vectorToWorldSpace(Vector3.new(0,0.707,-0.707)), Vector3.new(0,0.707,-0.707)
  534. end
  535. end
  536.  
  537. function HWallRun(part, pos, side)
  538. if (part.className == "Part" and part.Shape == Enum.PartType.Block) or part.className ~= "Part" then
  539. flow.Value = flow.Value + 9
  540. Standing = false
  541. HWallRunning = true
  542. Action = "HWallRunning"
  543. GravPoint = 10
  544. HWRLastPart = part
  545. local dir, dirc = FindSurface(part, pos)
  546. towall = -dir
  547. dir = (CFrame.new(NV, dir) * CFrame.Angles(0,side,0)).lookVector
  548.  
  549. local bv = Instance.new("BodyVelocity", Torsoz)
  550. bv.Name = "StaminaBodyObject"
  551. bv.maxForce = Vector3.new(1/0,1/0,1/0)
  552. bv.P = 9000
  553. bv.velocity = (dir*(sprint-0.5)) + Vector3.new(0,GravPoint,0)
  554. local bg = Instance.new("BodyGyro", Torsoz)
  555. bg.Name = "StaminaBodyObject"
  556. bg.maxTorque = Vector3.new(1/0,1/0,1/0)
  557. bg.cframe = CFrame.new(Torsoz.Position+(towall*-2), Torsoz.Position) * CFrame.Angles(0,-side,-side/4.2)
  558. bg.D = 100
  559.  
  560. local sid = Instance.new("Snap")
  561.  
  562. local joint1 = Joint3
  563. if side == -math.pi/2 then
  564. 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))
  565. else
  566. sid = joint1
  567. SetWeld(joint1,1,1, NV,NV, Vector3.new(1.4,0.6,0), Vector3.new(-math.pi/12,0,math.pi/7))
  568. end
  569. local j1c0 = joint1.C0
  570.  
  571. local joint2 = Joint4
  572. if side == math.pi/2 then
  573. 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))
  574. else
  575. sid = joint2
  576. SetWeld(joint2,1,1, NV,NV, Vector3.new(-1.4,0.6,0), Vector3.new(-math.pi/12,0,-math.pi/7))
  577. end
  578. local j2c0 = joint2.C0
  579.  
  580. local joint3 = Joint1
  581. joint3.C1 = CFrame.new(0,1,0)
  582. if side == -math.pi/2 then
  583. SetWeld(joint3,1,1, NV,NV, Vector3.new(0.5,-0.38,-0.3), Vector3.new(0,math.pi/2,0.14))
  584. else
  585. SetWeld(joint3,1,1, NV,NV, Vector3.new(0.5,-0.8,-0.2), Vector3.new(0,math.pi/2,0.2))
  586. end
  587.  
  588. local joint4 = Joint2
  589. joint4.C1 = CFrame.new(0,1,0)
  590. if side == -math.pi/2 then
  591. SetWeld(joint4,1,1, NV,NV, Vector3.new(-0.5,-0.8,-0.2), Vector3.new(0,0,0.2))
  592. else
  593. SetWeld(joint4,1,1, NV,NV, Vector3.new(-0.5,-0.38,-0.3), Vector3.new(0,0,0.14))
  594. end
  595.  
  596. local joint5 = Joint5
  597. SetWeld(joint5,1,1,NV,NV,Vector3.new(0,0.9,0),Vector3.new(0,0,side/7))
  598.  
  599. Torsoz.CFrame = CFrame.new(pos+(towall*-2), pos) * CFrame.Angles(0,-side,-side/2.2)
  600. bg.cframe = CFrame.new(pos+(towall*-2), pos) * CFrame.Angles(0,-side,-side/2.2)
  601.  
  602. local aniangle = 0
  603. local aniplus = true
  604. local aniangle2 = 0
  605. local aniplus2 = true
  606.  
  607. local prevpart = part
  608. HWRLastPart = part
  609. while HWallRunning == true do
  610.  
  611. if aniangle > math.pi then
  612. aniplus = false
  613. elseif aniangle < -math.pi then
  614. aniplus = true  
  615. end
  616. if aniplus == true then
  617. aniangle = aniangle + 0.95
  618. elseif aniplus == false then
  619. aniangle = aniangle - 0.95
  620. end
  621.  
  622. if aniangle2 > math.pi then
  623. aniplus2 = false
  624. elseif aniangle2 < -math.pi then
  625. aniplus2 = true  
  626. end
  627. if aniplus2 == true then
  628. aniangle2 = aniangle2 + 0.23
  629. elseif aniplus2 == false then
  630. aniangle2 = aniangle2 - 0.23
  631. end
  632.  
  633. Hu.PlatformStand = true
  634. local hitz, enz = RAY(Torsoz.Position, Vector3.new(0,-3,0))
  635. local hitz2, enz2 = RAY(Torsoz.Position, towall*3.4)
  636.  
  637. --- if player ends wall run on ground
  638. if hitz ~= nil and hitz.CanCollide == true then
  639. bg.cframe = CFrame.new(enz2+(towall*-2), enz2) * CFrame.Angles(0,-side,0)
  640. local offset = (bg.cframe.p.y+enz2.y) - bg.cframe.p.y
  641. Torsoz.CFrame = CFrame.new(Vector3.new(bg.cframe.p.x,offset,bg.cframe.p.z), enz2) * CFrame.Angles(0,-side,0)
  642. Torsoz.Velocity = NV
  643. break
  644. end
  645.  
  646. ---- if new wall found --------
  647. if hitz2 ~= nil and hitz2.CanCollide == true then
  648. if hitz2 ~= prevpart then
  649. local direct = CFrame.new(Torsoz.Position, Torsoz.Position+dir) * CFrame.Angles(0,side,0)
  650. local hitz3, enz3 = RAY(Torsoz.Position, (direct * CFrame.Angles(0,-side/2.3,0)).lookVector*4)
  651. if hitz3 ~= nil then
  652. Torsoz.CFrame = CFrame.new(enz2+(towall*-2), enz2) * CFrame.Angles(0,-side*1.1,-side/2.2)
  653. bg.cframe = CFrame.new(enz2+(towall*-2), enz2) * CFrame.Angles(0,-side*1.1,-side/2.2)
  654. dir, dirc = FindSurface(hitz2, enz2)
  655. towall = -dir
  656. dir = (CFrame.new(NV, dir) * CFrame.Angles(0,side,0)).lookVector
  657. prevpart = hitz2
  658. HWRLastPart = hitz2
  659. else
  660. ---- if player fails to find new wall to run on
  661. Torsoz.CFrame = CFrame.new(Torsoz.Position, Torsoz.Position+dir)
  662. bg.cframe = CFrame.new(Torsoz.Position, Torsoz.Position+dir)
  663. Torsoz.Velocity = NV
  664. HWRCooldown = 5
  665. break
  666. end
  667. end
  668. --- continue to wall run
  669. Torsoz.CFrame = CFrame.new(enz2+(towall*-2), enz2) * CFrame.Angles(0,-side,-side/2.2)
  670. bg.cframe = CFrame.new(enz2+(towall*-2), enz2) * CFrame.Angles(0,-side,-side/2.2)
  671. else
  672. ---- if player ends wall run at end of wall
  673. Torsoz.CFrame = CFrame.new(Torsoz.Position, Torsoz.Position+dir)
  674. bg.cframe = CFrame.new(Torsoz.Position, Torsoz.Position+dir)
  675. Torsoz.Velocity = NV
  676. HWRCooldown = 5
  677. break
  678. end
  679.  
  680. local hitz3, enz3 = RAY(Torsoz.Position, Torsoz.CFrame.lookVector*2)
  681. if hitz3 ~= nil and hitz3.CanCollide == true then
  682. Torsoz.CFrame = CFrame.new(Torsoz.Position, Torsoz.Position+dir)
  683. bg.cframe = CFrame.new(Torsoz.Position, Torsoz.Position+dir)
  684. Torsoz.Velocity = NV
  685. HWRCooldown = 5
  686. break
  687. end
  688.  
  689. bv.Parent = Torsoz
  690. bv.velocity = (dir*(sprint-0.5)) + Vector3.new(0,GravPoint,0)
  691. bg.cframe = bg.cframe * CFrame.Angles(aniangle/80,aniangle/80,0)
  692. Torsoz.CFrame = Torsoz.CFrame * CFrame.Angles(aniangle/80,aniangle/80,0)
  693. local j3,j3a = GetWeld(joint3)
  694. local j4,j4a = GetWeld(joint4)
  695. SetWeld(joint3,1,1, j3,j3a, j3,Vector3.new(-0.2+(aniangle/4),0,0))
  696. SetWeld(joint4,1,1, j4,j4a, j4,Vector3.new(-0.2+(-aniangle/4),0,0))
  697. if side == math.pi/2 then
  698. local j1,j1a = GetWeld(joint1)
  699. SetWeld(joint1,1,1, j1,j1a, j1, Vector3.new(0,0,0.8+(aniangle2/14)))
  700. else
  701. local j2,j2a = GetWeld(joint2)
  702. SetWeld(joint2,1,1, j2,j2a, j2, Vector3.new(0,0,-0.8-(aniangle2/14)))
  703. end
  704.  
  705. wait(0.025)
  706. if GravPoint < -100 then
  707. bg.cframe = CFrame.new(enz2+(towall*-2), enz2) * CFrame.Angles(0,-side,0)
  708. local offset = math.abs((bg.cframe.p.y+enz2.y) - bg.cframe.p.y)
  709. Torsoz.CFrame = CFrame.new(Vector3.new(bg.cframe.p.x,offset,bg.cframe.p.z), enz2) * CFrame.Angles(0,-side,0)
  710. break
  711. end
  712.  
  713. end
  714.  
  715. if HWallRunning == "Jumping" then
  716. HWRCooldown = 6
  717. joint1.C1 = CFrame.new(0,0.5,0)
  718.  
  719. joint2.C1 = CFrame.new(0,0.5,0)
  720. if side == -math.pi/2 then
  721. joint2.C0 = CFrame.new(-1.35,0.5,0) * CFrame.Angles(0,side/2.4,-math.pi/3)
  722. else
  723. joint2.C0 = CFrame.new(-1.35,0.5,0) * CFrame.Angles(0,side/2.4,-math.pi/4)
  724. end
  725.  
  726. joint3.C1 = CFrame.new(0,1,0)
  727. if side == -math.pi/2 then
  728. joint3.C0 = CFrame.new(0.5,-0.8,0) * CFrame.Angles(0,math.pi+(side/2.4),-math.pi/4)
  729. else
  730. joint3.C0 = CFrame.new(0.5,-0.8,0) * CFrame.Angles(0,(side/2.4),math.pi/4)
  731. end
  732. joint4.MaxVelocity = 10
  733. joint4.DesiredAngle = 0
  734. joint4.C1 = CFrame.new(0,1,0)
  735. if side == -math.pi/2 then
  736. joint4.C0 = CFrame.new(-0.5,-0.8,0) * CFrame.Angles(0,math.pi+(side/2.4),math.pi/4)
  737. else
  738. joint4.C0 = CFrame.new(-0.5,-0.8,0) * CFrame.Angles(0,(side/2.4),-math.pi/4)
  739. end
  740.  
  741. local joint5 = Joint5
  742. joint5.C1 = CFrame.new(0,-0.5,0) * CFrame.Angles(0,side/2.4,0)
  743. joint5.C0 = CFrame.new(0,1,0)
  744.  
  745. local j1,j1a = GetWeld(joint1)
  746. local j2,j2a = GetWeld(joint2)
  747. local j3,j3a = GetWeld(joint3)
  748. local j4,j4a = GetWeld(joint4)
  749. local j5,j5a = GetWeld(joint5)
  750.  
  751. GravPoint = 26
  752. local collidecount = 0
  753. local bgangle = side/2
  754. local count = 1
  755. local dir2 = (CFrame.new(NV, dir) * CFrame.Angles(0,-side/2.4,0)).lookVector
  756. HWRDir = dir2
  757. bv.velocity = (dir2*(sprint+5)) + Vector3.new(0,GravPoint,0)
  758. while HWallRunning == "Jumping" do
  759. local hitz, enz = RAY(Torsoz.Position, Vector3.new(0,-4,0))
  760. local hitz2, enz2 = RAY(Torsoz.Position, dir2*1.4)
  761. if hitz ~= nil and hitz.CanCollide == true then
  762. local offset = math.abs(enz.y - Torsoz.CFrame.p.y)
  763. Torsoz.CFrame = CFrame.new(enz+Vector3.new(0,2.9,0), enz+Vector3.new(0,2.9,0)+dir2)
  764. Torsoz.Velocity = NV
  765. break
  766. end
  767.  
  768. if hitz2 ~= nil and hitz2.CanCollide == true then
  769. collidecount = collidecount + 1
  770. if collidecount == 4 then
  771. Torsoz.CFrame = CFrame.new(Torsoz.Position, Torsoz.Position+dir2) * CFrame.new(0,0,0.4)
  772. Torsoz.Velocity = Vector3.new(0,Torsoz.Velocity.y,0)
  773. HWRCooldown = 5
  774. VWRCooldown = 5
  775. wait(0.02)
  776. break
  777. end
  778. end
  779.  
  780. if side/2 > 0 then
  781. if bgangle > 0.2 then
  782. bgangle = bgangle - 0.055
  783. end
  784. else
  785. if bgangle < -0.2 then
  786. bgangle = bgangle + 0.055
  787. end
  788. end
  789.  
  790. if count <= 5 then
  791. if side == -math.pi/2 then
  792. SetWeld(joint1,count,5, j1,j1a, Vector3.new(1.35,0.5,0), Vector3.new(0,side/2.4,math.pi/4))
  793. SetWeld(joint2,count,5, j2,j2a, Vector3.new(-1.35,0.5,0), Vector3.new(0,side/2.4,-math.pi/3))
  794. SetWeld(joint3,count,5, j3,j3a, Vector3.new(0.5,-0.8,0), Vector3.new(0,-side/1.7,0))
  795. joint3.C0 = joint3.C0 * CFrame.Angles((-math.pi/4)/5*count,0,0)
  796. SetWeld(joint4,count,5, j4,j4a, Vector3.new(-0.5,-0.8,0), Vector3.new(0,-side/1.7,0))
  797. joint4.C0 = joint4.C0 * CFrame.Angles((math.pi/4)/5*count,0,0)
  798. else
  799. SetWeld(joint1,count,5, j1,j1a, Vector3.new(1.35,0.5,0), Vector3.new(0,side/2.4,math.pi/3))
  800. SetWeld(joint2,count,5, j2,j2a, Vector3.new(-1.35,0.5,0), Vector3.new(0,side/2.4,-math.pi/4))
  801. SetWeld(joint3,count,5, j3,j3a, Vector3.new(0.5,-0.8,0), Vector3.new(0,-side/1.7,0))
  802. joint3.C0 = joint3.C0 * CFrame.Angles((math.pi/4)/5*count,0,0)
  803. SetWeld(joint4,count,5, j4,j4a, Vector3.new(-0.5,-0.8,0), Vector3.new(0,-side/1.7,0))
  804. joint4.C0 = joint4.C0 * CFrame.Angles((-math.pi/4)/5*count,0,0)
  805. end
  806.  
  807. count = count + 1
  808. end
  809.  
  810. bg.Parent = Torsoz
  811. bg.cframe = CFrame.new(NV, dir) * CFrame.Angles(0,side/15,-bgangle)
  812. bv.velocity = (dir2*(sprint+5)) + Vector3.new(0,GravPoint,0)
  813. if collidecount ~= 0 then
  814. bv.velocity = Vector3.new(0,bv.velocity.y,0)
  815. end
  816. if GravPoint < -120 then
  817. break
  818. end
  819. wait(0.025)
  820. end
  821. end
  822.  
  823. Hu.PlatformStand = false
  824. bv:remove()
  825.  
  826. HWRGravDrop = false
  827. Stand()
  828. HWallRunning = false
  829. end
  830. end
  831.  
  832. function VWR(part, pos)
  833. if (part.className == "Part" and part.Shape == Enum.PartType.Block) or part.className ~= "Part" then
  834. print("VWR Activated")
  835. flow.Value = flow.Value + 9
  836. Standing = false
  837. VWallRunning = true
  838. Action = "VWallRunning"
  839. GravPoint = 0
  840. local percent = 1
  841. VWRLastPart = part
  842. local dir, dirc = FindSurface(part, pos)
  843. towall = -dir
  844. dir = (CFrame.new(NV, -dir) * CFrame.Angles(math.pi/2,0,0)).lookVector
  845. --[[
  846. local p = P:Clone()
  847. p.Parent = char
  848. p.Size = Vector3.new(2,2,2)
  849. p.BrickColor = BrickColor.new("Lime green")
  850. p.CanCollide = false
  851. p.CFrame = part.CFrame * CFrame.new(dirc*5)
  852. p.Transparency = 0.3
  853. ]]
  854. local bv = Instance.new("BodyVelocity", Torsoz)
  855. bv.Name = "StaminaBodyObject"
  856. bv.maxForce = Vector3.new(1/0,1/0,1/0)
  857. bv.P = 9000
  858. bv.velocity = (dir*(sprint-1))*percent
  859.  
  860. local bg = Instance.new("BodyGyro", Torsoz)
  861. bg.Name = "StaminaBodyObject"
  862. bg.maxTorque = Vector3.new(1/0,1/0,1/0)
  863. bg.D = 100
  864. local posi = pos + (-towall*1.8)
  865. bg.cframe = CFrame.new(posi, posi+towall) * CFrame.Angles((math.pi/5),0,0)
  866. Torsoz.CFrame = CFrame.new(posi, posi+towall) * CFrame.Angles((math.pi/5),0,0)
  867.  
  868. local joint1 = Joint3
  869. SetWeld(joint1,1,1, NV,NV, Vector3.new(1.4,0.45,-0.1), Vector3.new(-math.pi/3.2,0,math.pi/8))
  870.  
  871. local joint2 = Joint4
  872. SetWeld(joint2,1,1, NV,NV, Vector3.new(-1.4,0.45,-0.1), Vector3.new(-math.pi/3.2,0,-math.pi/8))
  873.  
  874. local joint3 = Joint1
  875. SetWeld(joint3,1,1, NV,NV, Vector3.new(0.48,-0.6,-0.1), Vector3.new(0,math.pi/2,0))
  876. joint3.C1 = CFrame.new(0,0.7,0.2) * CFrame.Angles(0,math.pi/2,0)
  877.  
  878. local joint4 = Joint2
  879. SetWeld(joint4,1,1, NV,NV, Vector3.new(-0.48,-0.6,-0.1), Vector3.new(0,math.pi/2,0))
  880. joint4.C1 = CFrame.new(0,0.7,0.2) * CFrame.Angles(0,math.pi/2,0)
  881.  
  882. local joint5 = Joint5
  883. SetWeld(joint5,1,1, NV,NV, Vector3.new(0,1,0), Vector3.new(math.pi/20,0,0))
  884.  
  885. local aniangle = 0
  886. local aniplus = true
  887.  
  888. while VWallRunning == true do
  889. local hitz, enz = RAY(Torsoz.Position, towall*2.1)
  890. local hitz2, enz2 = RAY(Torsoz.Position, (CFrame.new(NV,towall)*CFrame.Angles(math.pi/2,0,0)).lookVector*2.4)
  891.  
  892. if aniangle > math.pi then
  893. aniplus = false
  894. elseif aniangle < -math.pi then
  895. aniplus = true  
  896. end
  897. if aniplus == true then
  898. aniangle = aniangle + (1.3*(percent+0.2))
  899. elseif aniplus == false then
  900. aniangle = aniangle - (1.3*(percent+0.2))
  901. end
  902.  
  903. bv.velocity = (dir*(sprint-1))*percent
  904. if VWRLeft == true then
  905. bv.velocity = bv.velocity + ((CFrame.new(NV, towall) * CFrame.Angles(0,math.pi/2,0)).lookVector * (11*percent+5))
  906. end
  907. if VWRRight == true then
  908. bv.velocity = bv.velocity - ((CFrame.new(NV, towall) * CFrame.Angles(0,math.pi/2,0)).lookVector * (11*percent+5))
  909. end
  910.  
  911. bg.cframe = CFrame.new(posi, posi+towall) * CFrame.Angles((math.pi/5),0,0) * CFrame.Angles(0,aniangle/60,0)
  912.  
  913. 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)))
  914. 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)))
  915. SetWeld(joint3,1,1, NV,NV, Vector3.new(0.51,-0.75,-(aniangle/30)), Vector3.new(0,math.pi/2,(aniangle/8)-0.3))
  916. SetWeld(joint4,1,1, NV,NV, Vector3.new(-0.51,-0.75,(aniangle/30)), Vector3.new(0,math.pi/2,(-aniangle/8)-0.3))
  917.  
  918. if hitz == nil then
  919. local lv = Torsoz.Position + (Torsoz.CFrame.lookVector*100)
  920. Torsoz.CFrame = CFrame.new(Torsoz.Position, Vector3.new(lv.x,Torsoz.Position.y,lv.z))
  921. break
  922. end
  923.  
  924. if hitz2 ~= nil then
  925. percent = 0
  926. VWallRunning = "Falling"
  927. Action = "VWRFalling"
  928. GravPoint = -7
  929. break
  930. end
  931.  
  932. wait(0.02)
  933. percent = percent - 0.028
  934. if percent <= 0.15 then
  935. VWallRunning = "Falling"
  936. Action = "VWRFalling"
  937. end
  938. end
  939.  
  940. -------------------------- Falling from VWR ------------------------------
  941. if VWallRunning == "Falling" then
  942. GravPoint = GravPoint - 1
  943. local dirpos = (-towall *5) + Vector3.new(0,GravPoint,0)
  944. bv.velocity = CFrame.new(NV, dirpos).lookVector * dirpos.magnitude
  945.  
  946. local j1,j1a = GetWeld(joint1)
  947. local j2,j2a = GetWeld(joint2)
  948. local j3,j3a = GetWeld(joint3)
  949. local j4,j4a = GetWeld(joint4)
  950. local j5,j5a = GetWeld(joint5)
  951.  
  952. local counter = 0
  953. while VWallRunning == "Falling" do
  954. counter = counter + 1
  955. local hitz, enz = RAY(H.Position, Vector3.new(0,-2.4,0))
  956.  
  957. dirpos = (-towall *5) + Vector3.new(0,GravPoint,0)
  958. bv.velocity = CFrame.new(NV, dirpos).lookVector * dirpos.magnitude
  959. if VWRLeft == true then
  960. bv.velocity = bv.velocity + ((CFrame.new(NV, towall) * CFrame.Angles(0,math.pi/2,0)).lookVector * 9)
  961. end
  962. if VWRRight == true then
  963. bv.velocity = bv.velocity - ((CFrame.new(NV, towall) * CFrame.Angles(0,math.pi/2,0)).lookVector * 9)
  964. end
  965. bg.cframe = CFrame.new(NV, (-towall*30) + Vector3.new(0,GravPoint,0)) * CFrame.Angles(-math.pi/2.55,math.pi,0)
  966.  
  967. if counter <= 35 then
  968. SetWeld(joint1,counter,35, j1,j1a, Vector3.new(1.4,0.45,-0.1), Vector3.new(math.pi/9,0,math.pi/9))
  969. SetWeld(joint2,counter,35, j2,j2a, Vector3.new(-1.4,0.45,-0.1), Vector3.new(math.pi/9,0,-math.pi/9))
  970. SetWeld(joint3,counter,35, j3,j3a, Vector3.new(0.5,-0.75,0), Vector3.new(0,math.pi/2,math.pi/9))
  971. joint3.C1 = CFrame.new(0,0.7 + (0.3/35*counter),0.2 - (0.2/35*counter)) * CFrame.Angles(0,math.pi/2,0)
  972. SetWeld(joint4,counter,35, j4,j4a, Vector3.new(-0.5,-0.75,0), Vector3.new(0,math.pi/2,math.pi/9))
  973. joint4.C1 = CFrame.new(0,0.7 + (0.3/35*counter),0.2 - (0.2/35*counter)) * CFrame.Angles(0,math.pi/2,0)
  974. SetWeld(joint5,counter,35, j5,j5a, Vector3.new(0,1,0), Vector3.new(-math.pi/6,0,0))
  975. end
  976.  
  977. if hitz ~= nil then
  978. bv:remove()
  979. 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)
  980. Torsoz.Velocity = NV
  981. Torsoz.RotVelocity = NV
  982. local bp = Instance.new("BodyPosition", Torsoz)
  983. bp.maxForce = Vector3.new(1/0,1/0,1/0)
  984. bp.position = Torsoz.CFrame.p
  985. game:service("Debris"):AddItem(bp, 0.16)
  986. flow.Value = 0
  987. break
  988. end
  989.  
  990. if GravPoint > - 180 then
  991. GravPoint = GravPoint - 1.9
  992. end
  993. if counter > 200 then
  994. break
  995. end
  996. wait(0.02)
  997. end
  998.  
  999. local bp = Instance.new("BodyPosition")
  1000.  
  1001. local counter2 = counter
  1002. local bgangleplus = 0
  1003.  
  1004. local j1,j1a = GetWeld(joint1)
  1005. local j2,j2a = GetWeld(joint2)
  1006. local j3,j3a = GetWeld(joint3)
  1007. local j4,j4a = GetWeld(joint4)
  1008. local j5,j5a = GetWeld(joint5)
  1009.  
  1010. local landingpos
  1011.  
  1012. while VWallRunning == "BackflipFromFall" do
  1013. counter2 = counter2 + 1
  1014. local hitz, enz = RAY(H.Position+Vector3.new(0,2,0), Vector3.new(0,-4.4,0))
  1015.  
  1016. if counter2 - counter < 13 then
  1017. bgangleplus = bgangleplus - ((math.pi*1.1)/13)
  1018. end
  1019. if counter2 - counter <= 13 then
  1020. 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))
  1021. 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))
  1022. SetWeld(joint3,counter2-counter,13, j3,j3a, Vector3.new(0.52,-0.3,-0.65), Vector3.new(0,math.pi/2,0))
  1023. SetWeld(joint4,counter2-counter,13, j4,j4a, Vector3.new(-0.51,-0.9,-0.05), Vector3.new(0,math.pi/2,0))
  1024. SetWeld(joint5,counter2-counter,13, j5,j5a, Vector3.new(0,0.9,0), Vector3.new(-math.pi/7,0,0))
  1025. end
  1026.  
  1027. dirpos = (-towall *5) + Vector3.new(0,GravPoint,0)
  1028. --bv.velocity = Vector3.new(0,-2,0)
  1029. bv.velocity = CFrame.new(NV, dirpos).lookVector * dirpos.magnitude
  1030. if VWRLeft == true then
  1031. bv.velocity = bv.velocity + ((CFrame.new(NV, towall) * CFrame.Angles(0,math.pi/2,0)).lookVector * 9)
  1032. end
  1033. if VWRRight == true then
  1034. bv.velocity = bv.velocity - ((CFrame.new(NV, towall) * CFrame.Angles(0,math.pi/2,0)).lookVector * 9)
  1035. end
  1036. bg.cframe = CFrame.new(NV, (-towall*30) + Vector3.new(0,GravPoint,0)) * CFrame.Angles((-math.pi/2.4) + bgangleplus,math.pi,0)
  1037.  
  1038. if hitz ~= nil then
  1039. bv:remove()
  1040. landingpos = enz - (towall*1.3)
  1041. if counter2 - counter > 8 then
  1042. bp = Instance.new("BodyPosition", Torsoz)
  1043. bp.maxForce = Vector3.new(1/0,1/0,1/0)
  1044. bp.position = enz+Vector3.new(0,2.4,0) + (-towall*1)
  1045. VWallRunning = "LandingFall"
  1046. else
  1047. Torsoz.CFrame = bg.cframe + (enz+Vector3.new(0,2.3,0))
  1048. Torsoz.Velocity = NV
  1049. Torsoz.RotVelocity = NV
  1050. local bp = Instance.new("BodyPosition", Torsoz)
  1051. bp.maxForce = Vector3.new(1/0,1/0,1/0)
  1052. bp.position = Torsoz.CFrame.p
  1053. game:service("Debris"):AddItem(bp, 0.14)
  1054. flow.Value = 0
  1055. end
  1056. break
  1057. end
  1058.  
  1059. if GravPoint > - 180 then
  1060. GravPoint = GravPoint - 1.9
  1061. end
  1062. if counter2 > 200 then
  1063. break
  1064. end
  1065. wait(0.02)
  1066. end
  1067.  
  1068. if VWallRunning == "LandingFall" then
  1069. print("Landing")
  1070.  
  1071. joint3.C1 = CFrame.new(0,1,0) * CFrame.Angles(0,math.pi/2,0)
  1072. joint4.C1 = CFrame.new(0,1,0) * CFrame.Angles(0,math.pi/2,0)
  1073. local j1,j1a = GetWeld(joint1)
  1074. local j2,j2a = GetWeld(joint2)
  1075. local j3,j3a = GetWeld(joint3)
  1076. local j4,j4a = GetWeld(joint4)
  1077. local j5,j5a = GetWeld(joint5)
  1078.  
  1079. local a
  1080. local mesh
  1081. if GravPoint < -70 then
  1082. a = P:Clone()
  1083. a.Parent = Torsoz
  1084. a.Name = "AirLandingEffect"
  1085. a.BrickColor = BrickColor.new("Medium stone grey")
  1086. a.Transparency = 0.3
  1087. a.CFrame = CFrame.new(landingpos+Vector3.new(0,0.4,0))
  1088. mesh = Instance.new("SpecialMesh", a)
  1089. mesh.MeshId = "http://www.roblox.com/asset/?id=20329976"
  1090. mesh.Scale = Vector3.new(0,0,0)
  1091. end
  1092.  
  1093. local bgcf = CFrame.new(NV, Vector3.new(towall.x,0,towall.z))
  1094. bg.cframe = bgcf * CFrame.Angles(-math.pi/7,0,0)
  1095. local bgval = math.pi/7/2
  1096.  
  1097. for i = 1, 6 do
  1098. Hu.PlatformStand = true
  1099. 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))
  1100. 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))
  1101. SetWeld(joint3,i,6, j3,j3a, Vector3.new(0.51,-0.3,-0.8), Vector3.new(0,math.pi/2,-math.pi/7))
  1102. SetWeld(joint4,i,6, j4,j4a, Vector3.new(-0.51,-0.8,-0.7), Vector3.new(0,math.pi/2,-math.pi/3))
  1103. SetWeld(joint5,i,6, j5,j5a, Vector3.new(0,0.85,0), Vector3.new(-math.pi/8,0,0))
  1104. bp.position = bp.position + Vector3.new(0,-0.07,0)
  1105. bg.cframe = bgcf * CFrame.Angles((-bgval*2) + (bgval/6*i),0,0)
  1106. Torsoz.CFrame = bg.cframe + bp.position
  1107. if a ~= nil then
  1108. mesh.Scale = mesh.Scale + Vector3.new(1.3,0.35,1.3)
  1109. a.Transparency = 0.3 + (0.7/6*i)
  1110. end
  1111. wait(0.02)
  1112. end
  1113. if a ~= nil then
  1114. a:remove()
  1115. end
  1116. local j1,j1a = GetWeld(joint1)
  1117. local j2,j2a = GetWeld(joint2)
  1118. local j3,j3a = GetWeld(joint3)
  1119. local j4,j4a = GetWeld(joint4)
  1120. local j5,j5a = GetWeld(joint5)
  1121. for i = 1, 6 do
  1122. Hu.PlatformStand = true
  1123. SetWeld(joint1,i,6, j1,j1a, Vector3.new(1.5,0.5,0), Vector3.new(0,0,0))
  1124. SetWeld(joint2,i,6, j2,j2a, Vector3.new(-1.5,0.5,0), Vector3.new(0,0,0))
  1125. SetWeld(joint3,i,6, j3,j3a, Vector3.new(0.5,-1,0), Vector3.new(0,math.pi/2,0))
  1126. SetWeld(joint4,i,6, j4,j4a, Vector3.new(-0.5,-1,0), Vector3.new(0,math.pi/2,0))
  1127. SetWeld(joint5,i,6, j5,j5a, Vector3.new(0,1,0), Vector3.new(0,0,0))
  1128. bp.position = bp.position + Vector3.new(0,0.1,0)
  1129. bg.cframe = bgcf * CFrame.Angles(-bgval + (bgval/6*i),0,0)
  1130. Torsoz.CFrame = bg.cframe + bp.position
  1131. wait(0.02)
  1132. end
  1133.  
  1134. bp:remove()
  1135. end
  1136.  
  1137. end
  1138.  
  1139. bv:remove()
  1140. bg:remove()
  1141. VWallRunning = false
  1142. Stand()
  1143. end
  1144. end
  1145.  
  1146. function Slide(pos)
  1147. flow.Value = flow.Value + 6
  1148. Action = "Sliding"
  1149. Sliding = true
  1150. GravPoint = Torsoz.Velocity.y
  1151. local spd = Vector3.new(Torsoz.Velocity.x,0,Torsoz.Velocity.z).magnitude + 10
  1152. local dir = Vector3.new(Torsoz.Velocity.x,0,Torsoz.Velocity.z).unit
  1153.  
  1154. local bv = Instance.new("BodyVelocity", Torsoz)
  1155. bv.maxForce = Vector3.new(1/0,1/0,1/0)
  1156. bv.velocity = dir*spd
  1157. local bg = Instance.new("BodyGyro", Torsoz)
  1158. bg.maxTorque = Vector3.new(1/0,1/0,1/0)
  1159. bg.cframe = CFrame.new(NV, dir) * CFrame.Angles(math.pi/2.2,0.24,0)
  1160.  
  1161. local joint1 = Joint1
  1162. local joint2 = Joint2
  1163. local joint3 = Joint3
  1164. local joint4 = Joint4
  1165. local joint5 = Joint5
  1166. local j1,j1a = GetWeld(joint1)
  1167. local j2,j2a = GetWeld(joint2)
  1168.  
  1169. SetWeld(joint1,1,1, NV,NV, Vector3.new(j1.x,j1.y,j1.z), Vector3.new(j1a.x,math.pi/2,j1a.z))
  1170. joint1.C1 = CFrame.new(0,1,0) * CFrame.Angles(0,math.pi/2,0)
  1171. SetWeld(joint2,1,1, NV,NV, Vector3.new(j2.x,j2.y,j2.z), Vector3.new(j2a.x,math.pi/2,j2a.z))
  1172. joint2.C1 = CFrame.new(0,1,0) * CFrame.Angles(0,math.pi/2,0)
  1173.  
  1174. local j1,j1a = GetWeld(joint1)
  1175. local j2,j2a = GetWeld(joint2)
  1176. local j3,j3a = GetWeld(joint3)
  1177. local j4,j4a = GetWeld(joint4)
  1178. local j5,j5a = GetWeld(joint5)
  1179.  
  1180. local count = 0
  1181. local lastpos
  1182.  
  1183. while Sliding == true do
  1184. count = count + 1
  1185. Hu.PlatformStand = true
  1186. local hitz1, enz1 = RAY(Torsoz.Position+Vector3.new(0,0.03,0), dir *2.5)
  1187. local hitz2, enz2 = RAY(Torsoz.Position-Vector3.new(0,0.2,0), dir *2.5)
  1188. local ghitz, genz = RAY(Torsoz.Position, Vector3.new(0,-2.6,0))
  1189. bv.velocity = dir*spd + Vector3.new(0,GravPoint,0)
  1190.  
  1191. if count <= 5 then
  1192. SetWeld(joint1,count,5, j1,j1a, Vector3.new(0.5,-0.8,-0.15), Vector3.new(0,(math.pi/2)+0.1,-0.4))
  1193. SetWeld(joint2,count,5, j2,j2a, Vector3.new(-0.5,-1,0), Vector3.new(0,(math.pi/2)-0.4,0))
  1194. SetWeld(joint3,count,5, j3,j3a, Vector3.new(1.5,0.5,0), Vector3.new(-0.7,-0.24,math.pi/5))
  1195. SetWeld(joint4,count,5, j4,j4a, Vector3.new(-1.5,0.5,0), Vector3.new(-0.1,0,-math.pi/1.5))
  1196. SetWeld(joint5,count,5, j5,j5a, Vector3.new(0,1,0), Vector3.new(-0.5,-0.2,0))
  1197. end
  1198.  
  1199. if (hitz1 ~= nil and hitz1.CanCollide == true) or (hitz2 ~= nil and  hitz2.CanCollide == true) then
  1200. bv:remove()
  1201. bg:remove()
  1202. Sliding = "HitObject"
  1203. end
  1204. if ghitz ~= nil then
  1205. GravPoint = 0
  1206. Torsoz.CFrame = CFrame.new(genz, genz+dir) * CFrame.Angles(math.pi/2.2,0.24,0) + Vector3.new(0,0.7,0)
  1207. spd = spd - 0.95
  1208. else
  1209. if GravPoint > -180 then
  1210. GravPoint = GravPoint - 5.6
  1211. end
  1212. spd = spd - 0.36
  1213. end
  1214. if spd < 7 then
  1215. Sliding = false
  1216. end
  1217. wait(0.02)
  1218. end
  1219.  
  1220. if Sliding == false then
  1221. local j1,j1a = GetWeld(joint1)
  1222. local j2,j2a = GetWeld(joint2)
  1223. local j3,j3a = GetWeld(joint3)
  1224. local j4,j4a = GetWeld(joint4)
  1225. local j5,j5a = GetWeld(joint5)
  1226. for i = 1, 4 do
  1227. SetWeld(joint1,i,4, j1,j1a, Vector3.new(0.5,-1,0), Vector3.new(0,math.pi/2,0))
  1228. SetWeld(joint2,i,4, j2,j2a, Vector3.new(-0.5,-1,0), Vector3.new(0,math.pi/2,0))
  1229. SetWeld(joint3,i,4, j3,j3a, Vector3.new(1.5,0.5,0), NV)
  1230. SetWeld(joint4,i,4, j4,j4a, Vector3.new(-1.5,0.5,0), NV)
  1231. SetWeld(joint5,i,4, j5,j5a, Vector3.new(0,1,0), NV)
  1232. local hitz, enz = RAY(Torsoz.Position, Vector3.new(0,-2.6,0))
  1233. 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)
  1234. bv.velocity = dir*spd + Vector3.new(0,GravPoint,0)
  1235.  
  1236. if hitz ~= nil then
  1237. GravPoint = 0
  1238. 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)
  1239. spd = spd - 0.95
  1240. else
  1241. if GravPoint > -180 then
  1242. GravPoint = GravPoint - 5.6
  1243. end
  1244. spd = spd - 0.36
  1245. end
  1246. wait(0.02)
  1247. end
  1248. local hitz, enz = RAY(Torsoz.Position, Vector3.new(0,-2.6,0))
  1249. Torsoz.CFrame = CFrame.new(enz, enz+dir) + Vector3.new(0,3,0)
  1250. end
  1251. bv:remove()
  1252. bg:remove()
  1253. SlideCooldown = 10
  1254. Stand()
  1255. end
  1256.  
  1257. function KD(key)
  1258. if pause.Value == false then
  1259. if key == string.char(32) then
  1260. Space = true
  1261.  
  1262. local ghitz, genz = RAY(Torsoz.Position, Vector3.new(0,-3.7,0))
  1263. local hitz, enz = RAY(Torsoz.Position+Vector3.new(0,1.1,0), Torsoz.CFrame.lookVector*2.3)
  1264. local righthitz, rightenz
  1265. local lefthitz, leftenz
  1266.  
  1267. if HWallRunning == false then
  1268. righthitz, rightenz = RAY(Torsoz.Position, ((Torsoz.CFrame * CFrame.new(1.5,0,-0.2)).p - Torsoz.CFrame.p).unit*3.9)
  1269. lefthitz, leftenz = RAY(Torsoz.Position, ((Torsoz.CFrame * CFrame.new(-1.5,0,-0.2)).p - Torsoz.CFrame.p).unit*3.9)
  1270.  
  1271. elseif HWallRunning == "Jumping" then
  1272. 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)
  1273. 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)
  1274.  
  1275. end
  1276.  
  1277. 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
  1278. if stamina >= 10 then
  1279. --if Vector3.new(Torsoz.Velocity.x,0,Torsoz.Velocity.z).magnitude > 12 then
  1280. Dive()
  1281. --end
  1282. end
  1283. end
  1284.  
  1285. if hitz == nil and VWallRunning == "Falling" then
  1286. VWallRunning = "BackflipFromFall"
  1287. end
  1288.  
  1289. if Shift == true and Torsoz.Velocity.y > -50 and Diving == false and DivingCooldown <= 0 then
  1290. local hitz2, enz2 = RAY(Torsoz.Position, Vector3.new(0,-3.5,0))
  1291.  
  1292. if hitz ~= nil then
  1293. if Action == "Standing" and VWRCooldown == 0 then
  1294. if hitz2 == nil or hitz2.CanCollide == false then
  1295. VWR(hitz, enz)
  1296. end
  1297. end
  1298. end
  1299.  
  1300. if (HWallRunning == false or (HWallRunning == "Jumping" and (HWRLastPart ~= righthitz or HWRLastPart ~= lefthitz))) and HWRCooldown == 0 and VWallRunning == false then
  1301.  
  1302. 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
  1303. if hitz2 == nil or hitz2.CanCollide == false then
  1304. local right = (rightenz - Torsoz.Position).magnitude
  1305. local left = (leftenz - Torsoz.Position).magnitude
  1306. if right < left then
  1307. if HWallRunning == "Jumping" and HWRLastPart ~= righthitz then
  1308. HWallRunning = false
  1309. while Standing == false do
  1310. wait(0.01)
  1311. end
  1312. print("2nd Right Activated!")
  1313. HWallRun(righthitz, rightenz, -math.pi/2)
  1314. else
  1315. if hitz == nil then
  1316. print("Right Activated")
  1317. HWallRun(righthitz, rightenz, -math.pi/2)
  1318. end
  1319. end
  1320. elseif left < right then
  1321. if HWallRunning == "Jumping" and HWRLastPart ~= lefthitz then
  1322. HWallRunning = false
  1323. while Standing == false do
  1324. wait(0.01)
  1325. end
  1326. print("2nd Left Activated!")
  1327. HWallRun(lefthitz, leftenz, math.pi/2)
  1328. else
  1329. if hitz == nil then
  1330. print("Left Activated")
  1331. HWallRun(lefthitz, leftenz, math.pi/2)
  1332. end
  1333. end
  1334. end
  1335. end
  1336. end
  1337. end
  1338.  
  1339. end
  1340.  
  1341. if HWallRunning == true then
  1342. HWallRunning = "Jumping"
  1343. Action = "HWRJumping"
  1344. end
  1345.  
  1346. elseif key == string.char(48) then
  1347. Shift = true
  1348. elseif key == string.char(50) then
  1349. if Action == "Standing" then
  1350. Sit()
  1351. elseif HWallRunning == true then
  1352. HWRGravDrop = true
  1353. end
  1354. elseif key == string.char(52) then
  1355. 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
  1356. print("Sliding")
  1357. Slide()
  1358. end
  1359. elseif key == "a" then
  1360. VWRLeft = true
  1361. elseif key == "d" then
  1362. VWRRight = true
  1363. end
  1364. end
  1365. end
  1366.  
  1367. function KU(key)
  1368. if key == string.char(32) then
  1369. Space = false
  1370. elseif key == string.char(48) then
  1371. Shift = false
  1372. elseif key == string.char(50) then
  1373. if Action == "Sitting" then
  1374. Stand()
  1375. end
  1376. elseif key == string.char(52) then
  1377. Sliding = false
  1378. elseif key == "a" then
  1379. VWRLeft = false
  1380. elseif key == "d" then
  1381. VWRRight = false
  1382. end
  1383. end
  1384.  
  1385. mouse.KeyDown:connect(function(key) KD(key) end)
  1386. mouse.KeyUp:connect(function(key) KU(key) end)
  1387.  
  1388. Joint1 = Instance.new("Snap", Torsoz)
  1389. GetWeld(Joint1)
  1390. Joint2 = Instance.new("Snap", Torsoz)
  1391. GetWeld(Joint2)
  1392. Joint3 = Instance.new("Snap", Torsoz)
  1393. GetWeld(Joint3)
  1394. Joint4 = Instance.new("Snap", Torsoz)
  1395. GetWeld(Joint4)
  1396. Joint5 = Instance.new("Snap", Torsoz)
  1397. GetWeld(Joint5)
  1398. Stand()
  1399.  
  1400. local animatebg = Instance.new("BodyGyro")
  1401. animatebg.D = 100
  1402. local GravAction = "Idle"
  1403. local PrevGravAction = GravAction
  1404.  
  1405. local prevrapos = (RA.CFrame * CFrame.new(0,-1,0)).p
  1406. local prevlapos = (LA.CFrame * CFrame.new(0,-1,0)).p
  1407. local hue = 0
  1408. local recyclecount = 0
  1409. local tickoffset = tick()
  1410. local fadetab = {}
  1411. local fadetab2 = {}
  1412. local animatebgcount = 0
  1413.  
  1414. for i = 1, 13 do
  1415. local p = P:Clone()
  1416. p.Name = "Part"..i
  1417. local mesh = Instance.new("SpecialMesh", p)
  1418. mesh.MeshId = "http://www.roblox.com/Asset/?id=9856898"
  1419. mesh.TextureId = "http://www.roblox.com/Asset/?id=48358980"
  1420. table.insert(fadetab, {p, mesh})
  1421. end
  1422. for i = 1, 13 do
  1423. local p = P:Clone()
  1424. p.Name = "Part"..i
  1425. local mesh = Instance.new("SpecialMesh", p)
  1426. mesh.MeshId = "http://www.roblox.com/Asset/?id=9856898"
  1427. mesh.TextureId = "http://www.roblox.com/Asset/?id=48358980"
  1428. table.insert(fadetab2, {p, mesh})
  1429. end
  1430.  
  1431. game:service("RunService").Stepped:connect(function()
  1432. GravAction = "Idle"
  1433. hue = hue + 3
  1434. hue = hue % 360
  1435.  
  1436. ------------- anim angle changing --------
  1437. if animangle > math.pi then
  1438. animplus = false
  1439. elseif animangle < -math.pi then
  1440. animplus = true  
  1441. end
  1442. if animplus == true then
  1443. animangle = animangle + animspeed
  1444. elseif animplus == false then
  1445. animangle = animangle - animspeed
  1446. end
  1447.  
  1448. local hitz, enz = RAY(Torsoz.Position, Vector3.new(0,-3.9,0))
  1449. if Shift == true then
  1450. Hu.WalkSpeed = sprint
  1451. else
  1452. Hu.WalkSpeed = 16
  1453. end
  1454. if (FOV >= 70 and FOV < 74) and Vector3.new(Torsoz.Velocity.x,0,Torsoz.Velocity.z).magnitude > 25 then
  1455. FOV = FOV + 1
  1456. elseif (FOV <= 74 and FOV > 70) and Vector3.new(Torsoz.Velocity.x,0,Torsoz.Velocity.z).magnitude < 20 then
  1457. FOV = FOV - 1
  1458. end
  1459. if pause.Value == true then
  1460. Hu.WalkSpeed = 0
  1461. end
  1462. if Sitting == true then
  1463. local hitz2, enz2 = RAY(Torsoz.Position, Vector3.new(0,-2.2,0))
  1464. Hu.PlatformStand = true
  1465. if hitz2 == nil then
  1466. Stand()
  1467. end
  1468. end
  1469. if Diving == true then
  1470. Hu.PlatformStand = true
  1471. DivingBV.velocity = Vector3.new(DivingDir.x*(sprint+2),GravPoint,DivingDir.z*(sprint+2))
  1472. DivingBG.cframe = CFrame.new(Torsoz.Position, Torsoz.Position+DivingBV.velocity) * CFrame.Angles(-math.pi/2,0,0)
  1473.  
  1474. if GravPoint > -180 then
  1475. GravPoint = GravPoint - 2
  1476. end
  1477. end
  1478. if DivingCooldown > 0 then
  1479. DivingCooldown = DivingCooldown - 1
  1480. end
  1481. if HWallRunning == true then
  1482. if HWRGravDrop == false then
  1483. GravPoint = GravPoint - 0.4
  1484. else
  1485. GravPoint = GravPoint - 2
  1486. end
  1487. elseif HWallRunning == "Jumping" then
  1488. GravPoint = GravPoint - 1.7
  1489. end
  1490. ----------------------------- stamina ----------------------------------------
  1491. if Vector3.new(Torsoz.Velocity.x, 0, Torsoz.Velocity.z).magnitude > 18 and Action == "Standing" and Shift == true then
  1492. if stamina > 0 then
  1493. stamina = stamina - 0.5
  1494. if stamina < 0 then
  1495. Shift = false
  1496. stamina = 0
  1497. end
  1498. else
  1499. Shift = false
  1500. stamina = 0
  1501. end
  1502. if Action == "Standing" then
  1503. animspeed = 0.85
  1504. SetWeld(Joint1,1,1, NV,NV, Vector3.new(0.5,-1,0), Vector3.new(-animangle/4.85,0,0))
  1505. SetWeld(Joint2,1,1, NV,NV, Vector3.new(-0.5,-1,0), Vector3.new(animangle/4.85,0,0))
  1506. SetWeld(Joint3,1,1, NV,NV, Vector3.new(1.5,0.5,0), Vector3.new(animangle/3.5,0,0))
  1507. SetWeld(Joint4,1,1, NV,NV, Vector3.new(-1.5,0.5,0), Vector3.new(-animangle/3.5,0,0))
  1508. end
  1509. elseif Vector3.new(Torsoz.Velocity.x, 0, Torsoz.Velocity.z).magnitude > 12 and Action ~= "Sliding" then
  1510. if stamina < maxstamina then
  1511. stamina = stamina + 0.5
  1512. if stamina > maxstamina then
  1513. stamina = maxstamina
  1514. end
  1515. else
  1516. stamina = maxstamina
  1517. end
  1518. if Action == "Standing" then
  1519. animspeed = 0.65
  1520. SetWeld(Joint1,1,1, NV,NV, Vector3.new(0.5,-1,0), Vector3.new(-animangle/7,0,0))
  1521. SetWeld(Joint2,1,1, NV,NV, Vector3.new(-0.5,-1,0), Vector3.new(animangle/7,0,0))
  1522. SetWeld(Joint3,1,1, NV,NV, Vector3.new(1.5,0.5,0), Vector3.new(animangle/5,0,0))
  1523. SetWeld(Joint4,1,1, NV,NV, Vector3.new(-1.5,0.5,0), Vector3.new(-animangle/5,0,0))
  1524. end
  1525. elseif Vector3.new(Torsoz.Velocity.x, 0, Torsoz.Velocity.z).magnitude < 2 then
  1526. animspeed = 0.1
  1527. if Action == "Standing" then
  1528. SetWeld(Joint1,1,1, NV,NV, Vector3.new(0.5,-1,0), Vector3.new(-animangle/38,0,0))
  1529. SetWeld(Joint2,1,1, NV,NV, Vector3.new(-0.5,-1,0), Vector3.new(animangle/38,0,0))
  1530. SetWeld(Joint3,1,1, NV,NV, Vector3.new(1.5,0.5,0), Vector3.new(animangle/30,0,0))
  1531. SetWeld(Joint4,1,1, NV,NV, Vector3.new(-1.5,0.5,0), Vector3.new(-animangle/30,0,0))
  1532. end
  1533. if stamina < maxstamina then
  1534. if Sitting == false then
  1535. stamina = stamina + 0.65
  1536. else
  1537. stamina = stamina + 1.02
  1538. end
  1539. if stamina > maxstamina then
  1540. stamina = maxstamina
  1541. end
  1542. else
  1543. stamina = maxstamina
  1544. end
  1545. end
  1546.  
  1547. if hitz == nil then
  1548. if Torsoz.Velocity.y > 1 or (Torsoz.Velocity.y < -1 and Torsoz.Velocity.y > -90) then
  1549. if Action == "Standing" then
  1550. GravAction = "Rising"
  1551. animspeed = 0.1
  1552. SetWeld(Joint1,1,1, NV,NV, Vector3.new(0.5,-1,0), Vector3.new(-animangle/38,0,0))
  1553. SetWeld(Joint2,1,1, NV,NV, Vector3.new(-0.5,-1,0), Vector3.new(animangle/38,0,0))
  1554. SetWeld(Joint3,1,1, NV,NV, Vector3.new(1.5,0.5,0), Vector3.new((math.pi-0.2)+(animangle/30),0,0))
  1555. SetWeld(Joint4,1,1, NV,NV, Vector3.new(-1.5,0.5,0), Vector3.new((math.pi-0.2)+(-animangle/30),0,0))
  1556. if animatebg.Parent ~= nil then
  1557. animatebg.Parent = Torsoz
  1558. animatebg.maxTorque = Vector3.new(1/0,10000,1/0)
  1559. local lokvec = Torsoz.CFrame.lookVector*100
  1560. animatebg.cframe = CFrame.new(NV, Vector3.new(lokvec.x,0,lokvec.z))
  1561. animatebg.Parent = nil
  1562. end
  1563. end
  1564. end
  1565. end
  1566.  
  1567. if hitz == nil then
  1568. local hitz2, enz2 = RAY(Torsoz.Position, Vector3.new(0,-6,0))
  1569. if hitz2 == nil then
  1570. if Torsoz.Velocity.y < -90 then
  1571. if Action == "Standing" then
  1572. GravAction = "Falling"
  1573. animspeed = 1.1
  1574. animatebg.Parent = Torsoz
  1575. animatebg.maxTorque = Vector3.new(1/0,10000,1/0)
  1576. local lokvec = Torsoz.CFrame.lookVector*100
  1577. animatebg.cframe = CFrame.new(NV, Vector3.new(lokvec.x,0,lokvec.z)) * CFrame.Angles(-math.pi/11,animangle/70,0)
  1578. SetWeld(Joint1,1,1, NV,NV, Vector3.new(0.45,-0.8,0), Vector3.new((animangle/27)-0.3,0,0.18))
  1579. SetWeld(Joint2,1,1, NV,NV, Vector3.new(-0.45,-0.8,0), Vector3.new((-animangle/27)-0.3,0,-0.18))
  1580. SetWeld(Joint3,1,1, NV,NV, Vector3.new(1.4,0.5,0), Vector3.new((math.pi+0.2)+(animangle/26),0,0.18))
  1581. SetWeld(Joint4,1,1, NV,NV, Vector3.new(-1.4,0.5,0), Vector3.new((math.pi+0.2)+(-animangle/26),0,-0.18))
  1582. end
  1583. end
  1584. elseif hitz2.CanCollide == true then
  1585. if animatebg.Parent ~= nil then
  1586. animatebg.Parent = Torsoz
  1587. animatebg.maxTorque = Vector3.new(1/0,10000,1/0)
  1588. local lokvec = Torsoz.CFrame.lookVector*100
  1589. animatebg.cframe = CFrame.new(NV, Vector3.new(lokvec.x,0,lokvec.z))
  1590. animatebg.Parent = nil
  1591. end
  1592. end
  1593. end
  1594.  
  1595. if GravAction == "Idle" and animatebg.Parent ~= nil then
  1596. animatebg.Parent = nil
  1597. end
  1598.  
  1599. if math.abs(tickoffset - tick()) > 0.05 then
  1600. tickoffset = tick()
  1601. local flowcolor = HSV(hue, 0.7,1)
  1602. recyclecount = (recyclecount % #fadetab) + 1
  1603. if flow.Value > 25 then
  1604. local lapos = (LA.CFrame * CFrame.new(0,-1,0)).p
  1605. local rapos = (RA.CFrame * CFrame.new(0,-1,0)).p
  1606. local p = fadetab[recyclecount]
  1607. p[1].Parent = m
  1608. p[1].CFrame = CFrame.new((lapos+prevlapos)/2, lapos)
  1609. p[2].Scale = Vector3.new(0.5,0.5,(lapos-prevlapos).magnitude*2)
  1610. p[2].VertexColor = Vector3.new(flowcolor.r,flowcolor.g,flowcolor.b)
  1611. p[1].Transparency = math.abs((flow.Value/120) - 0.8)
  1612. p[1].Transparency = p[1].Transparency + (1/#fadetab)
  1613. local p = fadetab2[recyclecount]
  1614. p[1].Parent = m
  1615. p[1].CFrame = CFrame.new((rapos+prevrapos)/2, rapos)
  1616. p[2].Scale = Vector3.new(0.5,0.5,(rapos-prevrapos).magnitude*2)
  1617. p[2].VertexColor = Vector3.new(flowcolor.r,flowcolor.g,flowcolor.b)
  1618. p[1].Transparency = math.abs((flow.Value/120) - 0.8)
  1619. p[1].Transparency = p[1].Transparency + (1/#fadetab)
  1620. end
  1621.  
  1622. for i, v in pairs(fadetab) do
  1623. if v[1].Transparency < 0.9 then
  1624. v[1].Transparency = v[1].Transparency + (1/#fadetab)
  1625. fadetab2[i][1].Transparency = fadetab2[i][1].Transparency + (1/#fadetab)
  1626. elseif v[1].Transparency ~= 1 then
  1627. v[1].Transparency = 1
  1628. v[1].Position = Vector3.new(50000,0,0)
  1629. fadetab2[i][1].Transparency = 1
  1630. fadetab2[i][1].Position = Vector3.new(50000,0,0)
  1631. end
  1632. end
  1633.  
  1634. prevrapos = (RA.CFrame * CFrame.new(0,-1,0)).p
  1635. prevlapos = (LA.CFrame * CFrame.new(0,-1,0)).p
  1636. end
  1637.  
  1638. if flow.Value > 140 then
  1639. if char.Parent ~= nil then
  1640. char:remove()
  1641. end
  1642. end
  1643.  
  1644. if flowcooldown > 0 then
  1645. flowcooldown = flowcooldown - 1
  1646. end
  1647. if HWRCooldown > 0 then
  1648. HWRCooldown = HWRCooldown - 1
  1649. end
  1650. if VWRCooldown > 0 then
  1651. if hitz ~= nil and VWRCooldown > 0 then
  1652. VWRCooldown = VWRCooldown - 1
  1653. end
  1654. end
  1655. if SlideCooldown > 0 then
  1656. SlideCooldown = SlideCooldown - 1
  1657. end
  1658.  
  1659. if Action == "HWallRunning" or Action == "VWallRunning" then
  1660. flow.Value = flow.Value + 0.24
  1661. if flow.Value > 100 then
  1662. flow.Value = 100
  1663. end
  1664. flowcooldown = 40
  1665. elseif Action == "Diving" then
  1666. flowcooldown = 30
  1667. elseif Action == "Sliding" then
  1668. flowcooldown = 15
  1669. elseif Action == "Standing" or Action == "Sitting" then
  1670. if flow.Value > 0 and flowcooldown <= 0 then
  1671. flow.Value = flow.Value - 0.37
  1672. if flow.Value < 0 then
  1673. flow.Value = 0
  1674. end
  1675. end
  1676. end
  1677.  
  1678. cam.FieldOfView = FOV
  1679. prevanimbgcount = animatebgcount
  1680. sprint = defsprint + ((flow.Value/100)*2.4)
  1681. PrevGravAction = GravAction
  1682. Calculate()
  1683. end)
  1684.  
  1685.  
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700. self = script.Parent
  1701. c = workspace.CurrentCamera
  1702.  
  1703. player = game.Players.LocalPlayer
  1704. char = player.Character or player.CharacterAdded:wait()
  1705. humanoid = char:WaitForChild("Humanoid")
  1706.  
  1707. -- Apply some properties
  1708.  
  1709. player.CameraMaxZoomDistance = 0.5
  1710. c.FieldOfView = 100 -- Things get trippy if we don't do this.
  1711. humanoid.CameraOffset = Vector3.new(0,-0.01,-0.5)
  1712.  
  1713. function lock(part)
  1714.     if part and part:IsA("BasePart") then
  1715.         part.LocalTransparencyModifier = part.Transparency
  1716.         part.Changed:connect(function (property)
  1717.             part.LocalTransparencyModifier = part.Transparency
  1718.         end)
  1719.     end
  1720. end
  1721.  
  1722. for _,v in pairs(char:GetChildren()) do
  1723.     lock(v)
  1724. end
  1725.  
  1726. char.ChildAdded:connect(lock)
  1727.  
  1728. c.Changed:connect(function (property)
  1729.     if property == "CameraSubject" then
  1730.         if c.CameraSubject and c.CameraSubject:IsA("VehicleSeat") and humanoid then
  1731.             -- Vehicle seats try to change the camera subject to the seat itself. This isn't what we wan't really.
  1732.             c.CameraSubject = humanoid;
  1733.         end
  1734.     end
  1735. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement