Advertisement
soubrhomi

gun

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