Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.32 KB | None | 0 0
  1. local isScriptNil = false
  2.  
  3. local PlrName = "iHazle"
  4. local Plrs = game:GetService("Players")
  5. local RunService = game:GetService("RunService")
  6. local Content = game:GetService("ContentProvider")
  7. local LP = Plrs.LocalPlayer
  8. local Char = LP.Character
  9. local PlrGui = LP.PlayerGui
  10. local Backpack = LP.Backpack
  11. local Mouse = LP:GetMouse()
  12.  
  13.  
  14. local Camera = Workspace.CurrentCamera
  15. local LastCamCF = Camera.CoordinateFrame
  16. local AnimJoints = {}
  17. local Cons = {}
  18. local mDown = false
  19. local Multi = false
  20. local Grabbing = false
  21. local Current = {}
  22. local Alpha = 1
  23. local LightNum = 1
  24.  
  25. Current.Part = nil
  26. Current.BP = nil
  27. Current.BA = nil
  28. Current.Mass = nil
  29.  
  30. local LastPart = nil
  31.  
  32. local Head = Char["Head"]
  33. local Torso = Char["Torso"]
  34. local Humanoid = Char["Humanoid"]
  35. local LA = Char["Left Arm"]
  36. local RA = Char["Right Arm"]
  37. local LL = Char["Left Leg"]
  38. local RL = Char["Right Leg"]
  39.  
  40. local LS, RS;
  41.  
  42. local OrigLS = Torso["Left Shoulder"]
  43. local OrigRS = Torso["Right Shoulder"]
  44.  
  45. for _,v in pairs(Char:GetChildren()) do
  46. if v.Name == ModID then
  47. v:Destroy()
  48. end
  49. end
  50.  
  51. for _,v in pairs(PlrGui:GetChildren()) do
  52. if v.Name == "PadsGui" then
  53. v:Destroy()
  54. end
  55. end
  56.  
  57. local ModID = "Pads"
  58. local Objects = {}
  59. local Grav = 196.2
  60.  
  61. local sin=math.sin
  62. local cos=math.cos
  63. local max=math.max
  64. local min=math.min
  65. local atan2=math.atan2
  66. local random=math.random
  67. local tau = 2 * math.pi
  68.  
  69. local BodyObjects = {
  70. ["BodyVelocity"] = true;
  71. ["BodyAngularVelocity"] = true;
  72. ["BodyForce"] = true;
  73. ["BodyThrust"] = true;
  74. ["BodyPosition"] = true;
  75. ["RocketPropulsion"] = true;
  76. }
  77.  
  78. if LP.Name == PlrName and isScriptNil then
  79. script.Parent = nil
  80. end
  81.  
  82. LP.CameraMode = "Classic"
  83.  
  84. local Assets = {
  85. }
  86.  
  87. local LS0, LS1 = OrigLS.C0, OrigLS.C1
  88. local RS0, RS1 = OrigRS.C0, OrigRS.C1
  89.  
  90. for i,v in pairs(Assets) do
  91. local ID = tostring(Assets[i])
  92. Assets[i] = "http://www.roblox.com/asset/?id=" .. ID
  93. Content:Preload("http://www.roblox.com/asset/?id=" .. ID)
  94. end
  95.  
  96. function QuaternionFromCFrame(cf)
  97. local mx, my, mz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = cf:components();
  98. local trace = m00 + m11 + m22 if trace > 0 then
  99. local s = math.sqrt(1 + trace);
  100. local recip = 0.5/s;
  101. return (m21-m12)*recip, (m02-m20)*recip, (m10-m01)*recip, s*0.5;
  102. else
  103. local i = 0;
  104. if m11 > m00 then
  105. i = 1;
  106. end;
  107. if m22 > (i == 0 and m00 or m11) then
  108. i = 2 end if i == 0 then
  109. local s = math.sqrt(m00-m11-m22+1);
  110. local recip = 0.5/s return 0.5*s, (m10+m01)*recip, (m20+m02)*recip, (m21-m12)*recip;
  111. elseif i == 1 then
  112. local s = math.sqrt(m11-m22-m00+1);
  113. local recip = 0.5/s;
  114. return (m01+m10)*recip, 0.5*s, (m21+m12)*recip, (m02-m20)*recip ;
  115. elseif i == 2 then
  116. local s = math.sqrt(m22-m00-m11+1);
  117. local recip = 0.5/s;
  118. return (m02+m20)*recip, (m12+m21)*recip, 0.5*s, (m10-m01)*recip;
  119. end;
  120. end;
  121. end;
  122.  
  123. function QuaternionToCFrame(px, py, pz, x, y, z, w)
  124. local xs, ys, zs = x + x, y + y, z + z;
  125. local wx, wy, wz = w*xs, w*ys, w*zs;
  126. local xx = x*xs;
  127. local xy = x*ys;
  128. local xz = x*zs;
  129. local yy = y*ys;
  130. local yz = y*zs;
  131. local zz = z*zs;
  132. return CFrame.new(px, py, pz,1-(yy+zz), xy - wz, xz + wy,xy + wz, 1-(xx+zz), yz - wx, xz - wy, yz + wx, 1-(xx+yy))
  133. end;
  134.  
  135. function QuaternionSlerp(a, b, t)
  136. local cosTheta = a[1]*b[1] + a[2]*b[2] + a[3]*b[3] + a[4]*b[4];
  137. local startInterp, finishInterp;
  138. if cosTheta >= 0.0001 then
  139. if (1 - cosTheta) > 0.0001 then
  140. local theta = math.acos(cosTheta);
  141. local invSinTheta = 1/math.sin(theta);
  142. startInterp = math.sin((1-t)*theta)*invSinTheta;
  143. finishInterp = math.sin(t*theta)*invSinTheta;
  144. else
  145. startInterp = 1-t finishInterp = t;
  146. end;
  147. else
  148. if (1+cosTheta) > 0.0001 then
  149. local theta = math.acos(-cosTheta);
  150. local invSinTheta = 1/math.sin(theta);
  151. startInterp = math.sin((t-1)*theta)*invSinTheta;
  152. finishInterp = math.sin(t*theta)*invSinTheta;
  153. else startInterp = t-1 finishInterp = t;
  154. end;
  155. end;
  156. return a[1]*startInterp + b[1]*finishInterp, a[2]*startInterp + b[2]*finishInterp, a[3]*startInterp + b[3]*finishInterp, a[4]*startInterp + b[4]*finishInterp;
  157. end;
  158.  
  159. function CLerp(a,b,t)
  160. local qa={QuaternionFromCFrame(a)};
  161. local qb={QuaternionFromCFrame(b)};
  162. local ax,ay,az=a.x,a.y,a.z;
  163. local bx,by,bz=b.x,b.y,b.z;
  164. local _t=1-t;
  165. return QuaternionToCFrame(_t*ax+t*bx,_t*ay+t*by,_t*az+t*bz,QuaternionSlerp(qa, qb, t));
  166. end
  167.  
  168. function GetWeld(weld)
  169. local obj
  170. for i, v in pairs(AnimJoints) do
  171. if v[1] == weld then
  172. obj = v
  173. break
  174. end
  175. end
  176. if not obj then
  177. obj = {weld,NV}
  178. table.insert(AnimJoints,obj)
  179. end
  180. return weld.C0.p, obj[2]
  181. end
  182.  
  183. function SetWeld(weld, i, loops, origpos, origangle, nextpos, nextangle, override, overrideLower, smooth)
  184. smooth = smooth or 1
  185. local obj
  186. for i, v in pairs(AnimJoints) do
  187. if v[1] == weld then
  188. obj = v
  189. break
  190. end
  191. end
  192. if not obj then
  193. obj = {weld,NV}
  194. table.insert(AnimJoints,obj)
  195. end
  196.  
  197. local perc = (smooth == 1 and math.sin((math.pi/2)/loops*i)) or i/loops
  198.  
  199. local tox,toy,toz = 0,0,0
  200. tox = math.abs(origangle.x - nextangle.x) *perc
  201. toy = math.abs(origangle.y - nextangle.y) *perc
  202. toz = math.abs(origangle.z - nextangle.z) *perc
  203. tox = ((origangle.x > nextangle.x and -tox) or tox)
  204. toy = ((origangle.y > nextangle.y and -toy) or toy)
  205. toz = ((origangle.z > nextangle.z and -toz) or toz)
  206.  
  207. local tox2,toy2,toz2 = 0,0,0
  208. tox2 = math.abs(origpos.x - nextpos.x) *perc
  209. toy2 = math.abs(origpos.y - nextpos.y) *perc
  210. toz2 = math.abs(origpos.z - nextpos.z) *perc
  211. tox2 = (origpos.x > nextpos.x and -tox2) or tox2
  212. toy2 = (origpos.y > nextpos.y and -toy2) or toy2
  213. toz2 = (origpos.z > nextpos.z and -toz2) or toz2
  214.  
  215. obj[2] = Vector3.new(origangle.x + tox, origangle.y + toy, origangle.z + toz)
  216. weld.C0 = CFrame.new(origpos.x + tox2,origpos.y + toy2,origpos.z + toz2) * CFrame.Angles(origangle.x + tox,origangle.y + toy,origangle.z + toz)
  217. end
  218.  
  219. function RotateCamera(x, y)
  220. Camera.CoordinateFrame = CFrame.new(Camera.Focus.p) * (Camera.CoordinateFrame - Camera.CoordinateFrame.p) * CFrame.Angles(x, y, 0) * CFrame.new(0, 0, (Camera.CoordinateFrame.p - Camera.Focus.p).magnitude)
  221. end
  222.  
  223. function GetAngles(cf)
  224. local lv = cf.lookVector
  225. return -math.asin(lv.y), math.atan2(lv.x, -lv.z)
  226. end
  227.  
  228. local LastCamCF = Camera.CoordinateFrame
  229.  
  230. function Look()
  231. if AlphaOn == true then
  232. local x, y = GetAngles(LastCamCF:toObjectSpace(Camera.CoordinateFrame))
  233. Camera.CoordinateFrame = LastCamCF
  234. RotateCamera(x * -(Alpha), y * -(Alpha))
  235. LastCamCF = Camera.CoordinateFrame
  236. end
  237. end
  238.  
  239. function Cor(Func)
  240. local Ok, Err = coroutine.resume(coroutine.create(Func))
  241. if not Ok then
  242. print(Err)
  243. end
  244. end
  245.  
  246. function Cor2(Func)
  247. local Ok, Err = ypcall(Func)
  248. if not Ok then
  249. print(Err)
  250. end
  251. end
  252.  
  253. function MakePads()
  254. -- 1 - VTelekinesis
  255. P1 = Instance.new("Model")
  256. P1.Name = ModID
  257.  
  258. -- 2 - RBase
  259. P2 = Instance.new("Part")
  260. P2.CFrame = CFrame.new(Vector3.new(21.100008, 1.95000589, 11.899971)) * CFrame.Angles(-0, 0, -0)
  261. P2.FormFactor = Enum.FormFactor.Custom
  262. P2.Size = Vector3.new(0.799999952, 0.200000003, 0.800000012)
  263. P2.Anchored = true
  264. P2.BrickColor = BrickColor.new("White")
  265. P2.Friction = 0.30000001192093
  266. P2.Shape = Enum.PartType.Block
  267. P2.Name = "RBase"
  268. P2.Parent = P1
  269. P2.Transparency = 1
  270. -- 3 - Mesh
  271. P3 = Instance.new("CylinderMesh")
  272. P3.Scale = Vector3.new(1, 0.5, 1)
  273. P3.Parent = P2
  274.  
  275. -- 4 - LBase
  276. P4 = Instance.new("Part")
  277. P4.CFrame = CFrame.new(Vector3.new(18.100008, 1.95000589, 11.899971)) * CFrame.Angles(-0, 0, -0)
  278. P4.FormFactor = Enum.FormFactor.Custom
  279. P4.Size = Vector3.new(0.799999952, 0.200000003, 0.800000012)
  280. P4.Anchored = true
  281. P4.BrickColor = BrickColor.new("White")
  282. P4.Friction = 0.30000001192093
  283. P4.Shape = Enum.PartType.Block
  284. P4.Name = "LBase"
  285. P4.Parent = P1
  286. P4.Transparency = 1
  287. -- 5 - Mesh
  288. P5 = Instance.new("CylinderMesh")
  289. P5.Scale = Vector3.new(1, 0.5, 1)
  290. P5.Parent = P4
  291.  
  292. -- 7 - Mesh
  293. P7 = Instance.new("CylinderMesh")
  294. P7.Scale = Vector3.new(1, 0.5, 1)
  295. P7.Parent = P6
  296.  
  297.  
  298.  
  299. -- 9 - Mesh
  300. P9 = Instance.new("CylinderMesh")
  301. P9.Scale = Vector3.new(1, 0.5, 1)
  302. P9.Parent = P8
  303.  
  304.  
  305.  
  306. -- 11 - Mesh
  307. P11 = Instance.new("CylinderMesh")
  308. P11.Scale = Vector3.new(1, 0.5, 1)
  309. P11.Parent = P10
  310.  
  311.  
  312. -- 13 - Mesh
  313. P13 = Instance.new("CylinderMesh")
  314. P13.Scale = Vector3.new(1, 0.5, 1)
  315. P13.Parent = P12
  316.  
  317.  
  318. -- 15 - Mesh
  319. P15 = Instance.new("CylinderMesh")
  320. P15.Scale = Vector3.new(1, 0.5, 1)
  321. P15.Parent = P14
  322.  
  323. -- 17 - Mesh
  324. P17 = Instance.new("CylinderMesh")
  325. P17.Scale = Vector3.new(1, 0.5, 1)
  326. P17.Parent = P16
  327.  
  328. P1.Parent = LP.Character
  329. P1:MakeJoints()
  330. return P1
  331. end
  332.  
  333. weldModel = function(model, unanchor, rooty)
  334. local parts = {}
  335. local function recurse(object)
  336. if object:IsA("BasePart") then
  337. table.insert(parts, object)
  338. end
  339. for _,child in pairs(object:GetChildren()) do
  340. recurse(child)
  341. end
  342. end
  343. recurse(model)
  344.  
  345. local rootPart = rooty or parts[1]
  346. for _, part in pairs(parts) do
  347. local cframe = rootPart.CFrame:toObjectSpace(part.CFrame)
  348. local weld = Instance.new("Weld")
  349. weld.Part0 = rootPart
  350. weld.Part1 = part
  351. weld.C0 = cframe
  352. weld.Parent = rootPart
  353. end
  354.  
  355. if unanchor then
  356. for _, part in pairs(parts) do
  357. part.Anchored = false
  358. part.CanCollide = false
  359. end
  360. end
  361. end
  362.  
  363. weldItem = function(rootPart, Item, TheC0, unanchor, ParentItem)
  364. local cframe = TheC0 or rootPart.CFrame:toObjectSpace(Item.CFrame)
  365. local weld = Instance.new("Weld")
  366. weld.Name = "Weld"
  367. weld.Part0 = rootPart
  368. weld.Part1 = Item
  369. weld.C0 = cframe
  370. weld.Parent = ParentItem and Item or rootPart
  371.  
  372. if unanchor then
  373. Item.Anchored = false
  374. end
  375. return weld, cframe
  376. end
  377.  
  378. scaleModel = function(model, scale)
  379. local parts = {}
  380. local function recurse(object)
  381. if object:IsA("BasePart") then
  382. table.insert(parts, object)
  383. end
  384. for _,child in pairs(object:GetChildren()) do
  385. recurse(child)
  386. end
  387. end
  388. recurse(model)
  389.  
  390. local top, bottom, left, right, back, front
  391. for _, part in pairs(parts) do
  392. if top == nil or top < part.Position.y then top = part.Position.y end
  393. if bottom == nil or bottom > part.Position.y then bottom = part.Position.y end
  394. if left == nil or left > part.Position.x then left = part.Position.x end
  395. if right == nil or right < part.Position.x then right = part.Position.x end
  396. if back == nil or back > part.Position.z then back = part.Position.z end
  397. if front == nil or front < part.Position.z then front = part.Position.z end
  398. end
  399.  
  400. local middle = Vector3.new( left+right, top+bottom, back+front )/2
  401. local minSize = Vector3.new(0.2, 0.2, 0.2)
  402.  
  403. for _, part in pairs(parts) do
  404. local foo = part.CFrame.p - middle
  405. local rotation = part.CFrame - part.CFrame.p
  406. local newSize = part.Size*scale
  407. part.FormFactor = "Custom"
  408. part.Size = newSize
  409. part.CFrame = CFrame.new( middle + foo*scale ) * rotation
  410.  
  411. if newSize.x < minSize.x or newSize.y < minSize.y or newSize.z < minSize.z then
  412. local mesh
  413. for _, child in pairs(part:GetChildren()) do
  414. if child:IsA("DataModelMesh") then
  415. mesh = child
  416. break
  417. end
  418. end
  419.  
  420. if mesh == nil then
  421. mesh = Instance.new("BlockMesh", part)
  422. end
  423.  
  424. local oScale = mesh.Scale
  425. local newScale = newSize/minSize * oScale
  426. if 0.2 < newSize.x then newScale = Vector3.new(1 * oScale.x, newScale.y, newScale.z) end
  427. if 0.2 < newSize.y then newScale = Vector3.new(newScale.x, 1 * oScale.y, newScale.z) end
  428. if 0.2 < newSize.z then newScale = Vector3.new(newScale.x, newScale.y, 1 * oScale.z) end
  429.  
  430. mesh.Scale = newScale
  431. end
  432. end
  433. end
  434.  
  435. function getMass(Obj, Total)
  436. local newTotal = Total
  437. local returnTotal = 0
  438.  
  439. if Obj:IsA("BasePart") then
  440. newTotal = newTotal + Objects[Obj]
  441. elseif BodyObjects[Obj.ClassName] then
  442. Obj:Destroy()
  443. end
  444.  
  445. if Obj:GetChildren() and #Obj:GetChildren() > 0 then
  446. for _,v in pairs(Obj:GetChildren()) do
  447. returnTotal = returnTotal + getMass(v, newTotal)
  448. end
  449. else
  450. returnTotal = newTotal
  451. end
  452.  
  453. return returnTotal
  454. end
  455.  
  456. function getTargFromCurrent()
  457. local Current = Current.Part
  458. if Current:IsA("BasePart") then
  459. return Current
  460. elseif Current:findFirstChild("Torso") then
  461. return Current.Torso
  462. else
  463. for _,v in pairs(Current:GetChildren()) do
  464. if v:IsA("BasePart") then
  465. return v
  466. end
  467. end
  468. end
  469. end
  470.  
  471. function Fire(Part, Vec, Inv)
  472. pcall(function()
  473. Current.BP:Destroy()
  474. Current.BP = nil
  475. end)
  476. pcall(function()
  477. Current.BA:Destroy()
  478. Current.BA = nil
  479. end)
  480. pcall(function()
  481. if Inv then
  482. Part.Velocity = -((Vec - Torso.Position).unit * Grav * 1.1)
  483. else
  484. Part.Velocity = ((Vec - Camera.CoordinateFrame.p).unit * Grav * 1.1)
  485. end
  486. Current.Mass = nil
  487. end)
  488. Reset()
  489. end
  490.  
  491. function Reset()
  492. LS.Parent = nil
  493. RS.Parent = nil
  494.  
  495. OrigLS.Parent = Torso
  496. OrigRS.Parent = Torso
  497.  
  498. OrigLS.C0 = LS0
  499. OrigRS.C0 = RS0
  500. end
  501.  
  502. function Start()
  503. Cor(function()
  504. repeat wait(1/30) until LP.Character and LP.Character.Parent == Workspace and LP.Character:findFirstChild("Torso")
  505. Char = LP.Character
  506. PlrGui = LP.PlayerGui
  507. Backpack = LP.Backpack
  508. Mouse = LP:GetMouse()
  509.  
  510. for _,v in pairs(Cons) do
  511. v:disconnect()
  512. end
  513. Cons = {}
  514.  
  515. Camera = Workspace.CurrentCamera
  516. LastCamCF = Camera.CoordinateFrame
  517. AnimJoints = {}
  518. mDown = false
  519. Multi = false
  520. Grabbing = false
  521. Current = {}
  522. Alpha = 1
  523.  
  524. Head = Char["Head"]
  525. Torso = Char["Torso"]
  526. Humanoid = Char["Humanoid"]
  527. LA = Char["Left Arm"]
  528. RA = Char["Right Arm"]
  529. LL = Char["Left Leg"]
  530. RL = Char["Right Leg"]
  531.  
  532. OrigLS = Torso["Left Shoulder"]
  533. OrigRS = Torso["Right Shoulder"]
  534.  
  535. for _,v in pairs(Char:GetChildren()) do
  536. if v.Name == ModID then
  537. v:Destroy()
  538. end
  539. end
  540.  
  541. for _,v in pairs(PlrGui:GetChildren()) do
  542. if v.Name == "PadsGui" then
  543. v:Destroy()
  544. end
  545. end
  546.  
  547. LS = Instance.new("Weld")
  548. RS = Instance.new("Weld")
  549.  
  550. LS.Name = OrigLS.Name
  551. LS.Part0 = Torso
  552. LS.Part1 = LA
  553. LS.C0 = LS0
  554. LS.C1 = CFrame.new(0, 0.5, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0)
  555.  
  556. RS.Name = OrigRS.Name
  557. RS.Part0 = Torso
  558. RS.Part1 = RA
  559. RS.C0 = RS0
  560. RS.C1 = CFrame.new(0, 0.5, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0)
  561.  
  562. local Pads = MakePads()
  563. local LPad = Pads.LBase
  564. local RPad = Pads.RBase
  565.  
  566. weldModel(LPad, true, LPad)
  567. weldModel(RPad, true, RPad)
  568.  
  569. local GripWeldL = Instance.new("Weld")
  570. GripWeldL.Name = "GripWeldL"
  571. GripWeldL.Part0 = LA
  572. GripWeldL.Part1 = LPad
  573. GripWeldL.C0 = CFrame.new(0, -1.05, 0) * CFrame.Angles(0, math.rad(180), 0)
  574. GripWeldL.Parent = LA
  575.  
  576. local GripWeldR = Instance.new("Weld")
  577. GripWeldR.Name = "GripWeldR"
  578. GripWeldR.Part0 = RA
  579. GripWeldR.Part1 = RPad
  580. GripWeldR.C0 = CFrame.new(0, -1.05, 0) * CFrame.Angles(0, math.rad(180), 0)
  581. GripWeldR.Parent = RA
  582.  
  583. local isParts = false
  584.  
  585. table.insert(Cons, Mouse.KeyDown:connect(function(Key)
  586. Key = Key:lower()
  587. if Key == "z" then
  588. --Stuff
  589. elseif Key == "f" then
  590. local Current = Current.Part
  591. if Current and Current.Parent ~= nil and not Multi then
  592. Current:BreakJoints()
  593. end
  594. elseif Key == "q" then
  595. if isParts then
  596. isParts = false
  597. for _,v in pairs(Workspace:GetChildren()) do
  598. if v.Name == "MyPartV" and v:IsA("BasePart") then
  599. v:Destroy()
  600. end
  601. end
  602. else
  603. isParts = true
  604. for i = 1, 50 do
  605. local Part = Instance.new("Part")
  606. Part.Color = Color3.new(math.random(), math.random(), math.random())
  607. Part.Transparency = 0
  608. Part.Size = Vector3.new(math.random(1, 3), math.random(1, 3), math.random(1, 3))
  609. Part.Archivable = true
  610. Part.CanCollide = false
  611. Part.Material = "Neon"
  612. Part.Locked = false
  613. Part.CFrame = Torso.CFrame * CFrame.new(math.random(-15, 15), -1, math.random(-15, 15))
  614. Part.Anchored = true
  615. Part.Name = "MyPartV"
  616. Part.TopSurface = "Smooth"
  617. Part.BottomSurface = "Smooth"
  618. Part.Parent = Workspace
  619. end
  620. end
  621. elseif Key == "e" then
  622. local Targ;
  623. if Current.Part and Current.Part ~= nil then
  624. Targ = getTargFromCurrent()
  625. else
  626. Targ = LastPart
  627. end
  628. if Targ and Targ.Parent ~= nil and not Multi then
  629. local Ex = Instance.new("Explosion", Workspace)
  630. Ex.Position = Targ.CFrame.p
  631. Ex.BlastRadius = 16
  632. Ex.DestroyJointRadiusPercent = 0.5
  633. end
  634. elseif Key == "c" then
  635. if Current.Part and Current.Part.Parent ~= nil and not Multi then
  636. local Part = getTargFromCurrent()
  637. if Part then
  638. Grabbing = false
  639. if Mouse.Hit then
  640. local TargPos = CFrame.new(Camera.CoordinateFrame.p, Mouse.Hit.p) * CFrame.new(0, 0, -1000)
  641. Fire(Part, TargPos.p)
  642. else
  643. Fire(Part, Mouse.Origin.p + Mouse.UnitRay.Direction, true)
  644. end
  645. end
  646. end
  647. end
  648. end))
  649.  
  650. table.insert(Cons, Mouse.Button1Up:connect(function()
  651. mDown = false
  652. if Grabbing == true and Multi == false then
  653. Grabbing = false
  654. Reset()
  655. end
  656. if Current.Part ~= nil then
  657. LastPart = getTargFromCurrent()
  658. Current = {}
  659. end
  660. end))
  661.  
  662. local function makeLightning(Par, Start, End, Width, Length, RandomScale, ArcScale, Num1)
  663. local oldParts = {}
  664. for _,v in pairs(Par:GetChildren()) do
  665. v.CFrame = CFrame.new(5e5, 5e5, 5e5)
  666. table.insert(oldParts, v)
  667. end
  668. local Distance = (Start-End).Magnitude
  669. local ArcScale = ArcScale or 1
  670. local RandomScale = RandomScale or 0
  671. local Last = Start
  672. local IterNum = 0
  673.  
  674. while Par.Parent do
  675. IterNum = IterNum + 1
  676. local New = nil
  677. if (Last-End).Magnitude < Length then
  678. New = CFrame.new(End)
  679. else
  680. if (End-Last).Magnitude < Length*2 then
  681. RandomScale = RandomScale*0.5
  682. ArcScale = ArcScale*0.5
  683. end
  684. local Direct = CFrame.new(Last,End)
  685. New = Direct*CFrame.Angles(math.rad(math.random(-RandomScale/4,RandomScale*ArcScale)),math.rad(math.random(-RandomScale,RandomScale)),math.rad(math.random(-RandomScale,RandomScale)))
  686. New = New*CFrame.new(0,0,-Length)
  687. end
  688. local Trail = nil
  689. if oldParts[IterNum] then
  690. Trail = oldParts[IterNum]
  691. Trail.BrickColor = ((Num1 % 2 == 0) and BrickColor.new("White")) or BrickColor.new("Cyan")
  692. Trail.Size = Vector3.new(Width, (Last-New.p).Magnitude, Width)
  693. Trail.CFrame = CFrame.new(New.p, Last)*CFrame.Angles(math.rad(90),0,0)*CFrame.new(0, -(Last-New.p).Magnitude/2, 0)
  694. oldParts[IterNum] = nil
  695. else
  696. Trail = Instance.new("Part")
  697. Trail.Name = "Part"
  698. Trail.FormFactor = "Custom"
  699. Trail.BrickColor = ((Num1 % 2 == 0) and BrickColor.new("White")) or BrickColor.new("White")
  700. Trail.Transparency = 0
  701. Trail.Anchored = true
  702. Trail.CanCollide = false
  703. Trail.Locked = true
  704. Trail.BackSurface = "SmoothNoOutlines"
  705. Trail.BottomSurface = "SmoothNoOutlines"
  706. Trail.FrontSurface = "SmoothNoOutlines"
  707. Trail.LeftSurface = "SmoothNoOutlines"
  708. Trail.RightSurface = "SmoothNoOutlines"
  709. Trail.TopSurface = "SmoothNoOutlines"
  710. Trail.Material = "Neon"
  711. Trail.Size = Vector3.new(Width, (Last-New.p).Magnitude, Width)
  712. Trail.CFrame = CFrame.new(New.p, Last)*CFrame.Angles(math.rad(90),0,0)*CFrame.new(0, -(Last-New.p).Magnitude/2, 0)
  713. Trail.Parent = Par
  714. end
  715. Last = New.p
  716. if (Last-End).Magnitude < 1 then
  717. break
  718. end
  719. end
  720. for _,v in pairs(oldParts) do
  721. v:Destroy()
  722. end
  723. end
  724.  
  725. table.insert(Cons, Mouse.Button1Down:connect(function()
  726. mDown = true
  727. local Targ = Mouse.Target
  728. Cor(function()
  729. if Targ and Objects[Targ] and not Multi then
  730. Grabbing = true
  731. Current.Part = Targ
  732. local Mass = Objects[Targ]
  733. local ForceNum = 0
  734. local Hum = nil
  735.  
  736. for _,v in pairs(Targ:GetChildren()) do
  737. if BodyObjects[v.ClassName] then
  738. v:Destroy()
  739. end
  740. end
  741.  
  742. for _,v in pairs(Workspace:GetChildren()) do
  743. if v:findFirstChild("Humanoid") and v:IsAncestorOf(Targ) then
  744. Hum = v.Humanoid
  745. Mass = getMass(v, 0)
  746. Current.Part = v
  747. break
  748. end
  749. end
  750.  
  751. Current.Mass = Mass
  752.  
  753. if not Hum then
  754. Targ:BreakJoints()
  755. end
  756.  
  757. ForceNum = Mass * Grav
  758. Targ.CanCollide = true
  759. Targ.Anchored = false
  760.  
  761. local BP = Instance.new("BodyPosition")
  762. BP.maxForce = Vector3.new(3 * ForceNum, 3 * ForceNum, 3 * ForceNum)
  763. BP.Parent = Targ
  764.  
  765. local Ang = Instance.new("BodyAngularVelocity")
  766. Ang.Parent = Targ
  767.  
  768. Current.BP = BP
  769. Current.BA = Ang
  770.  
  771. OrigLS.Parent = nil
  772. OrigRS.Parent = nil
  773.  
  774. LS.Parent = Torso
  775. RS.Parent = Torso
  776.  
  777. LS.C0 = LS0
  778. RS.C0 = RS0
  779.  
  780. local DirDot = Mouse.UnitRay.Direction:Dot(Targ.Position - Mouse.Origin.p)
  781. local BPPos = Vector3.new(0, 0, 0)
  782. local Vel = Vector3.new(0, 0, 0)
  783. local Vlev = random() * math.pi
  784. local RPos = Vector3.new(random() * 2 - 1, cos(Vlev), random() * 2 - 1)
  785.  
  786. local Ball = Instance.new("Part")
  787. Ball.Name = "Ball"
  788. Ball.FormFactor = "Custom"
  789. Ball.Color = Color3.new(0, 1, 1)
  790. Ball.Transparency = 0.3
  791. Ball.Anchored = true
  792. Ball.CanCollide = false
  793. Ball.Locked = true
  794. Ball.BottomSurface, Ball.TopSurface = "Smooth", "Smooth"
  795. Ball.Size = Vector3.new(0.5, 0.5, 0.5)
  796. Ball.CFrame = Torso.CFrame * CFrame.new(0, 1, -3)
  797. Ball.Parent = Char
  798.  
  799. if Targ.Name == "MyPartV" then
  800. Targ.Name = "MyPartF"
  801. end
  802.  
  803. local LightMod = Instance.new("Model", Char)
  804.  
  805. local Mesh = Instance.new("SpecialMesh")
  806. Mesh.MeshType = "Sphere"
  807. Mesh.Parent = Ball
  808.  
  809. local Size = 0.5
  810. local Rise = true
  811.  
  812. while Grabbing and BP and Ang and Targ.Parent ~= nil do
  813. local BPPos = Mouse.Origin.p + Mouse.UnitRay.Direction * DirDot
  814. Ang.angularvelocity = Vel
  815. BP.position = BPPos + RPos
  816. RPos = Vector3.new(max(-1, min(RPos.x + random() * 0.02 - 0.01, 1)), cos(Vlev), max(-1, min(RPos.z + random() * 0.02 - 0.01, 1)))
  817. Vel = Vector3.new(max(-1, min(Vel.x + random() * 0.2 - 0.1, 1)), max(-1, min(Vel.y + random() * 0.2 - 0.1, 1)), max(-1, min(Vel.z + random() * 0.2 - 0.1, 1)))
  818. Vlev = (Vlev + 0.05) % tau
  819.  
  820. if Hum then
  821. Hum.Sit = true
  822. end
  823.  
  824. if LA.Parent ~= nil and RA.Parent ~= nil then
  825. local LPos = (LA.CFrame * CFrame.new(0, -1, 0)).p
  826. local RPos = (RA.CFrame * CFrame.new(0, -1, 0)).p
  827. if Rise == true then
  828. if Size < 0.6 then
  829. Size = Size + 0.05
  830. else
  831. Size = Size + 0.1
  832. end
  833. if Size >= 2.2 then
  834. Rise = false
  835. end
  836. else
  837. if Size > 2.1 then
  838. Size = Size - 0.05
  839. else
  840. Size = Size - 0.1
  841. end
  842. if Size <= 0.5 then
  843. Rise = true
  844. end
  845. end
  846. Ball.Size = Vector3.new(Size, Size, Size)
  847. Ball.CFrame = CFrame.new(LPos:Lerp(RPos, 0.5), Targ.Position) * CFrame.new(0, 0, -2.2)
  848. LightNum = LightNum + 1
  849. makeLightning(LightMod, Ball.Position, Targ.Position, 0.2, 4, 50, 1, LightNum)
  850. elseif Ball.Parent ~= nil then
  851. Ball:Destroy()
  852. end
  853.  
  854. if LS and LS.Parent == Torso then
  855. LS.C0 = CFrame.new(Vector3.new(-1.5, 0.5, 0), Torso.CFrame:pointToObjectSpace((Targ.CFrame or Torso.CFrame * CFrame.new(-1.5, 0.5, 1)).p))
  856. end
  857. if RS and RS.Parent == Torso then
  858. RS.C0 = CFrame.new(Vector3.new(1.5, 0.5, 0), Torso.CFrame:pointToObjectSpace((Targ.CFrame or Torso.CFrame * CFrame.new(1.5, 0.5, 1)).p))
  859. end
  860. RunService.Heartbeat:wait()
  861. end
  862.  
  863. coroutine.resume(coroutine.create(function()
  864. for i = 0.5, 1, 0.1 do
  865. for i2,v in pairs(LightMod:GetChildren()) do
  866. --v.Light.Range = 6-(i*5)
  867. v.Transparency = i
  868. end
  869. wait(1/30)
  870. end
  871. LightMod:Destroy()
  872. end))
  873.  
  874. if BP and BP.Parent ~= nil then
  875. BP:Destroy()
  876. end
  877.  
  878. if Ang and Ang.Parent ~= nil then
  879. Ang:Destroy()
  880. end
  881.  
  882. pcall(function() Ball:Destroy() end)
  883. end
  884. end)
  885. end))
  886. end)
  887. end
  888.  
  889. function Add(Obj)
  890. if Obj:IsA("BasePart") and not Objects[Obj] and not (Obj.Name == "Base" and Obj.ClassName == "Part") then
  891. Objects[Obj] = Obj:GetMass()
  892. Obj.Changed:connect(function(P)
  893. if P:lower() == "size" and Objects[Obj] and Obj.Parent ~= nil then
  894. Objects[Obj] = Obj:GetMass()
  895. end
  896. end)
  897. end
  898. end
  899.  
  900. function Rem(Obj)
  901. if Objects[Obj] then
  902. Objects[Obj] = nil
  903. end
  904. end
  905.  
  906. function Recursion(Obj)
  907. ypcall(function()
  908. Add(Obj)
  909. if #Obj:GetChildren() > 0 then
  910. for _,v in pairs(Obj:GetChildren()) do
  911. Recursion(v)
  912. end
  913. end
  914. end)
  915. end
  916.  
  917. Workspace.DescendantAdded:connect(function(Obj)
  918. Add(Obj)
  919. end)
  920.  
  921. Workspace.DescendantRemoving:connect(function(Obj)
  922. Rem(Obj)
  923. end)
  924.  
  925. for _,v in pairs(Workspace:GetChildren()) do
  926. Recursion(v)
  927. end
  928.  
  929. Start()
  930.  
  931. if LP.Name == PlrName then
  932. LP.CharacterAdded:connect(Start)
  933. end
  934.  
  935. local verlet = {}
  936. verlet.step_time = 1 / 50
  937. verlet.gravity = Vector3.new(0, -10, 0)
  938.  
  939. local char = game.Players.LocalPlayer.Character
  940. local torso = char:WaitForChild("Torso")
  941. local parts = {}
  942. local render = game:GetService("RunService").RenderStepped
  943.  
  944. wait(2)
  945.  
  946. local point = {}
  947. local link = {}
  948. local rope = {}
  949.  
  950. local function ccw(A,B,C)
  951. return (C.y-A.y) * (B.x-A.x) > (B.y-A.y) * (C.x-A.x)
  952. end
  953.  
  954. local function intersect(A,B,C,D)
  955. return ccw(A,C,D) ~= ccw(B,C,D) and ccw(A,B,C) ~= ccw(A,B,D)
  956. end
  957.  
  958. local function vec2(v)
  959. return Vector2.new(v.x, v.z)
  960. end
  961.  
  962. function point:step()
  963. if not self.fixed then
  964. local derivative = (self.position - self.last_position) * 0.95
  965. self.last_position = self.position
  966. self.position = self.position + derivative + (self.velocity * verlet.step_time ^ 2)
  967. --[[local torsoP = torso.CFrame * CFrame.new(-1, 0, 0.5)
  968. local torsoE = torso.CFrame * CFrame.new(1, 0, 0.5)
  969. local pointE = self.position + torso.CFrame.lookVector * 100
  970. local doIntersect = intersect(vec2(torsoP.p), vec2(torsoE.p), vec2(self.position), vec2(pointE))
  971. if not doIntersect then
  972. self.postition = self.position - torso.CFrame.lookVector * 10
  973. end]]
  974. end
  975. end
  976.  
  977. function link:step()
  978. for i = 1, 1 do
  979. local distance = self.point1.position - self.point2.position
  980. local magnitude = distance.magnitude
  981. local differance = (self.length - magnitude) / magnitude
  982. local translation = ((self.point1.fixed or self.point2.fixed) and 1 or 0.6) * distance * differance
  983. if not self.point1.fixed then
  984. self.point1.position = self.point1.position + translation
  985. end
  986. if not self.point2.fixed then
  987. self.point2.position = self.point2.position - translation
  988. end
  989. end
  990. end
  991.  
  992. function verlet.new(class, a, b, c)
  993. if class == "Point" then
  994. local new = {}
  995. setmetatable(new, {__index = point})
  996. new.class = class
  997. new.position = a or Vector3.new()
  998. new.last_position = new.position
  999. new.velocity = verlet.gravity
  1000. new.fixed = false
  1001. return new
  1002. elseif class == "Link" then
  1003. local new = {}
  1004. setmetatable(new, {__index = link})
  1005. new.class = class
  1006. new.point1 = a
  1007. new.point2 = b
  1008. new.length = c or (a.position - b.position).magnitude
  1009. return new
  1010. elseif class == "Rope" then
  1011. local new = {}
  1012. setmetatable(new, {__index = link})
  1013. new.class = class
  1014. new.start_point = a
  1015. new.finish_point = b
  1016. new.points = {}
  1017. new.links = {}
  1018. local inc = (b - a) / 10
  1019. for i = 0, 10 do
  1020. table.insert(new.points, verlet.new("Point", a + (i * inc)))
  1021. end
  1022. for i = 2, #new.points do
  1023. table.insert(new.links, verlet.new("Link", new.points[i - 1], new.points[i]))
  1024. end
  1025. return new
  1026. end
  1027. end
  1028.  
  1029. local tris = {}
  1030. local triParts = {}
  1031.  
  1032. local function GetDiscoColor(hue)
  1033. local section = hue % 1 * 3
  1034. local secondary = 0.5 * math.pi * (section % 1)
  1035. if section < 1 then
  1036. return Color3.new(0, 0, 0)
  1037. elseif section < 2 then
  1038. return Color3.new(0, 0, 0)
  1039. else
  1040. return Color3.new(0, 0, 0)
  1041. end
  1042. end
  1043.  
  1044. local function setupPart(part)
  1045. part.Anchored = true
  1046. part.FormFactor = 3
  1047. part.CanCollide = false
  1048. part.TopSurface = 10
  1049. part.BottomSurface = 10
  1050. part.LeftSurface = 10
  1051. part.RightSurface = 10
  1052. part.FrontSurface = 10
  1053. part.BackSurface = 10
  1054. part.Material = "Neon"
  1055. local m = Instance.new("SpecialMesh", part)
  1056. m.MeshType = "Wedge"
  1057. m.Scale = Vector3.new(0.2, 1, 1)
  1058. return part
  1059. end
  1060.  
  1061. local function CFrameFromTopBack(at, top, back)
  1062. local right = top:Cross(back)
  1063. return CFrame.new(at.x, at.y, at.z, right.x, top.x, back.x, right.y, top.y, back.y, right.z, top.z, back.z)
  1064. end
  1065.  
  1066. local function drawTri(parent, a, b, c)
  1067. local this = {}
  1068. local mPart1 = table.remove(triParts, 1) or setupPart(Instance.new("Part"))
  1069. local mPart2 = table.remove(triParts, 1) or setupPart(Instance.new("Part"))
  1070. function this:Set(a, b, c)
  1071. local ab, bc, ca = b-a, c-b, a-c
  1072. local abm, bcm, cam = ab.magnitude, bc.magnitude, ca.magnitude
  1073. local edg1 = math.abs(0.5 + ca:Dot(ab)/(abm*abm))
  1074. local edg2 = math.abs(0.5 + ab:Dot(bc)/(bcm*bcm))
  1075. local edg3 = math.abs(0.5 + bc:Dot(ca)/(cam*cam))
  1076. if edg1 < edg2 then
  1077. if edg1 >= edg3 then
  1078. a, b, c = c, a, b
  1079. ab, bc, ca = ca, ab, bc
  1080. abm = cam
  1081. end
  1082. else
  1083. if edg2 < edg3 then
  1084. a, b, c = b, c, a
  1085. ab, bc, ca = bc, ca, ab
  1086. abm = bcm
  1087. else
  1088. a, b, c = c, a, b
  1089. ab, bc, ca = ca, ab, bc
  1090. abm = cam
  1091. end
  1092. end
  1093.  
  1094. local len1 = -ca:Dot(ab)/abm
  1095. local len2 = abm - len1
  1096. local width = (ca + ab.unit*len1).magnitude
  1097.  
  1098. local maincf = CFrameFromTopBack(a, ab:Cross(bc).unit, -ab.unit)
  1099.  
  1100. if len1 > 0.2 then
  1101. mPart1.Parent = parent
  1102. mPart1.Size = Vector3.new(0.2, width, len1)
  1103. mPart1.CFrame = maincf*CFrame.Angles(math.pi,0,math.pi/2)*CFrame.new(0,width/2,len1/2)
  1104. else
  1105. mPart1.Parent = nil
  1106. end
  1107.  
  1108. if len2 > 0.2 then
  1109. mPart2.Parent = parent
  1110. mPart2.Size = Vector3.new(0.2, width, len2)
  1111. mPart2.CFrame = maincf*CFrame.Angles(math.pi,math.pi,-math.pi/2)*CFrame.new(0,width/2,-len1 - len2/2)
  1112. else
  1113. mPart2.Parent = nil
  1114. end
  1115. end
  1116. function this:SetProperty(prop, value)
  1117. mPart1[prop] = value
  1118. mPart2[prop] = value
  1119. end
  1120. this:Set(a, b, c)
  1121. function this:Destroy()
  1122. mPart1:Destroy()
  1123. mPart2:Destroy()
  1124. end
  1125. this.p1 = mPart1
  1126. this.p2 = mPart2
  1127. this.p1.BrickColor = BrickColor.new(GetDiscoColor(math.noise(0.5, 0.5, this.p1.CFrame.Y * 0.5 + time())))
  1128. this.p2.BrickColor = BrickColor.new(GetDiscoColor(math.noise(0.5, 0.5, this.p2.CFrame.Y * 0.5 + time())))
  1129. return this
  1130. end
  1131.  
  1132. function verlet.draw(object, id)
  1133. if object.class == "Point" then
  1134. local part = parts[id]
  1135. part.BrickColor = BrickColor.new(107, 0, 107)
  1136. part.Transparency = 0
  1137. part.formFactor = 3
  1138. part.Anchored = true
  1139. part.CanCollide = false
  1140. part.TopSurface = 0
  1141. part.BottomSurface = 0
  1142. part.Size = Vector3.new(0.35, 0.35, 0.35)
  1143. part.Material = "Neon"
  1144. part.CFrame = CFrame.new(object.position)
  1145. part.Parent = torso
  1146. return part
  1147. elseif object.class == "Link" then
  1148. local part = parts[id]
  1149. local dist = (object.point1.position - object.point2.position).magnitude
  1150. part.Size = Vector3.new(0.2, 0.2, dist)
  1151. part.CFrame = CFrame.new(object.point1.position, object.point2.position) * CFrame.new(0, 0, dist * -0.5)
  1152. part.Parent = torso
  1153. return part
  1154. end
  1155. end
  1156.  
  1157. function verlet.clear()
  1158. for _, v in pairs(workspace:GetChildren()) do
  1159. if v.Name == "Part" then
  1160. v:Destroy()
  1161. end
  1162. end
  1163. end
  1164.  
  1165. local points = {}
  1166. local links = {}
  1167.  
  1168. for x = 0, 2 do
  1169. points[x] = {}
  1170. for y = 0, 3 do
  1171. points[x][y] = verlet.new("Point", torso.Position + Vector3.new(x * 0.8 - 2, 2 - y * 0.8, 5 + y * 0.4))
  1172. points[x][y].fixed = y == 0
  1173. end
  1174. end
  1175.  
  1176. for x = 1, 2 do
  1177. for y = 0, 3 do
  1178. links[#links + 1] = verlet.new("Link", points[x][y], points[x - 1][y], 1 + y * 0.08)
  1179. end
  1180. end
  1181.  
  1182. for x = 0, 2 do
  1183. for y = 1, 3 do
  1184. links[#links + 1] = verlet.new("Link", points[x][y], points[x][y - 1], 1.2 + y * 0.03)
  1185. end
  1186. end
  1187.  
  1188. render:connect(function()
  1189. for x = 0, 2 do
  1190. for y = 0, 3 do
  1191. if y == 0 then
  1192. points[x][y].position = (torso.CFrame * CFrame.new(x * 1 - 1, 1, 0.5)).p
  1193. else
  1194. points[x][y]:step()
  1195. end
  1196. end
  1197. end
  1198. for i = 1, #links do
  1199. links[i]:step()
  1200. end
  1201. for i = 1, #tris do
  1202. triParts[#triParts + 1] = tris[i].p1
  1203. triParts[#triParts + 1] = tris[i].p2
  1204. end
  1205. tris = {}
  1206. for x = 1, 2 do
  1207. for y = 1, 3 do
  1208. tris[#tris + 1] = drawTri(torso, points[x - 1][y - 1].position, points[x - 1][y].position, points[x][y - 1].position)
  1209. tris[#tris + 1] = drawTri(torso, points[x][y].position, points[x - 1][y].position, points[x][y - 1].position)
  1210. end
  1211. end
  1212. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement