Advertisement
ghostteen14

Untitled

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