Advertisement
Demonlord27

telekenis1

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