Advertisement
antoniorigo4

here :)

Jan 8th, 2019
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.95 KB | None | 0 0
  1. --Converted with ttyyuu12345's model to script plugin v4
  2. function sandbox(var,func)
  3. local env = getfenv(func)
  4. local newenv = setmetatable({},{
  5. __index = function(self,k)
  6. if k=="script" then
  7. return var
  8. else
  9. return env[k]
  10. end
  11. end,
  12. })
  13. setfenv(func,newenv)
  14. return func
  15. end
  16. cors = {}
  17. mas = Instance.new("Model",game:GetService("Lighting"))
  18. Model0 = Instance.new("Model")
  19. Part1 = Instance.new("Part")
  20. Part2 = Instance.new("Part")
  21. Part3 = Instance.new("Part")
  22. Part4 = Instance.new("Part")
  23. Part5 = Instance.new("Part")
  24. Part6 = Instance.new("Part")
  25. ParticleEmitter7 = Instance.new("ParticleEmitter")
  26. Script8 = Instance.new("Script")
  27. Part9 = Instance.new("Part")
  28. Script10 = Instance.new("Script")
  29. Model0.Parent = mas
  30. Part1.Parent = Model0
  31. Part1.CFrame = CFrame.new(-2, 9, 32, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  32. Part1.Position = Vector3.new(-2, 9, 32)
  33. Part1.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  34. Part1.Size = Vector3.new(2, 2, 2)
  35. Part1.BottomSurface = Enum.SurfaceType.Smooth
  36. Part1.BrickColor = BrickColor.new("Really black")
  37. Part1.TopSurface = Enum.SurfaceType.Smooth
  38. Part1.brickColor = BrickColor.new("Really black")
  39. Part2.Parent = Model0
  40. Part2.CFrame = CFrame.new(-0.975000024, 9.5, 32, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  41. Part2.Orientation = Vector3.new(0, 90, 0)
  42. Part2.Position = Vector3.new(-0.975000024, 9.5, 32)
  43. Part2.Rotation = Vector3.new(0, 90, 0)
  44. Part2.Color = Color3.new(0, 1, 0)
  45. Part2.Size = Vector3.new(2, 1, 0.0500000007)
  46. Part2.BottomSurface = Enum.SurfaceType.Smooth
  47. Part2.BrickColor = BrickColor.new("Lime green")
  48. Part2.Material = Enum.Material.Neon
  49. Part2.TopSurface = Enum.SurfaceType.Smooth
  50. Part2.brickColor = BrickColor.new("Lime green")
  51. Part3.Parent = Model0
  52. Part3.CFrame = CFrame.new(-2, 9.5, 30.9750004, -1, 0, 0, 0, 1, 0, 0, 0, -1)
  53. Part3.Orientation = Vector3.new(0, 180, 0)
  54. Part3.Position = Vector3.new(-2, 9.5, 30.9750004)
  55. Part3.Rotation = Vector3.new(-180, 0, -180)
  56. Part3.Color = Color3.new(0, 1, 0)
  57. Part3.Size = Vector3.new(2, 1, 0.0500000007)
  58. Part3.BottomSurface = Enum.SurfaceType.Smooth
  59. Part3.BrickColor = BrickColor.new("Lime green")
  60. Part3.Material = Enum.Material.Neon
  61. Part3.TopSurface = Enum.SurfaceType.Smooth
  62. Part3.brickColor = BrickColor.new("Lime green")
  63. Part4.Parent = Model0
  64. Part4.CFrame = CFrame.new(-3.0250001, 9.5, 32, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  65. Part4.Orientation = Vector3.new(0, -90, 0)
  66. Part4.Position = Vector3.new(-3.0250001, 9.5, 32)
  67. Part4.Rotation = Vector3.new(0, -90, 0)
  68. Part4.Color = Color3.new(0, 1, 0)
  69. Part4.Size = Vector3.new(2, 1, 0.0500000007)
  70. Part4.BottomSurface = Enum.SurfaceType.Smooth
  71. Part4.BrickColor = BrickColor.new("Lime green")
  72. Part4.Material = Enum.Material.Neon
  73. Part4.TopSurface = Enum.SurfaceType.Smooth
  74. Part4.brickColor = BrickColor.new("Lime green")
  75. Part5.Name = "Handle"
  76. Part5.Parent = Model0
  77. Part5.CFrame = CFrame.new(-2, 7.5, 32, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  78. Part5.Position = Vector3.new(-2, 7.5, 32)
  79. Part5.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  80. Part5.Size = Vector3.new(2, 1, 2)
  81. Part5.BottomSurface = Enum.SurfaceType.Smooth
  82. Part5.BrickColor = BrickColor.new("Really black")
  83. Part5.TopSurface = Enum.SurfaceType.Smooth
  84. Part5.brickColor = BrickColor.new("Really black")
  85. Part6.Name = "KillPart"
  86. Part6.Parent = Model0
  87. Part6.CFrame = CFrame.new(-2, 6.9749999, 32, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  88. Part6.Position = Vector3.new(-2, 6.9749999, 32)
  89. Part6.Color = Color3.new(1, 0, 0)
  90. Part6.Size = Vector3.new(2, 0.0500000007, 2)
  91. Part6.BottomSurface = Enum.SurfaceType.Smooth
  92. Part6.BrickColor = BrickColor.new("Really red")
  93. Part6.Material = Enum.Material.Neon
  94. Part6.TopSurface = Enum.SurfaceType.Smooth
  95. Part6.brickColor = BrickColor.new("Really red")
  96. ParticleEmitter7.Parent = Part6
  97. ParticleEmitter7.Color = ColorSequence.new(Color3.new(1, 0, 0),Color3.new(1, 0, 0))
  98. ParticleEmitter7.LightInfluence = 1
  99. ParticleEmitter7.Lifetime = NumberRange.new(0.5, 0.5)
  100. Script8.Parent = Part6
  101. table.insert(cors,sandbox(Script8,function()
  102. script.parent.Touched:connect(function(hit)
  103. if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
  104. hit.Parent.Humanoid.Health = 0
  105. end
  106. end)
  107. end))
  108. Part9.Parent = Model0
  109. Part9.CFrame = CFrame.new(-2, 9.5, 33.0250015, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  110. Part9.Position = Vector3.new(-2, 9.5, 33.0250015)
  111. Part9.Color = Color3.new(0, 1, 0)
  112. Part9.Size = Vector3.new(2, 1, 0.0500000007)
  113. Part9.BottomSurface = Enum.SurfaceType.Smooth
  114. Part9.BrickColor = BrickColor.new("Lime green")
  115. Part9.Material = Enum.Material.Neon
  116. Part9.TopSurface = Enum.SurfaceType.Smooth
  117. Part9.brickColor = BrickColor.new("Lime green")
  118. Script10.Name = "qPerfectionWeld"
  119. Script10.Parent = Model0
  120. table.insert(cors,sandbox(Script10,function()
  121. -- Created by Quenty (@Quenty, follow me on twitter).
  122. -- Should work with only ONE copy, seamlessly with weapons, trains, et cetera.
  123. -- Parts should be ANCHORED before use. It will, however, store relatives values and so when tools are reparented, it'll fix them.
  124.  
  125. --[[ INSTRUCTIONS
  126. - Place in the model
  127. - Make sure model is anchored
  128. - That's it. It will weld the model and all children.
  129.  
  130. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  131. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  132. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  133. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  134. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  135. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  136. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  137. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  138.  
  139. This script is designed to be used is a regular script. In a local script it will weld, but it will not attempt to handle ancestory changes.
  140. ]]
  141.  
  142. --[[ DOCUMENTATION
  143. - Will work in tools. If ran more than once it will not create more than one weld. This is especially useful for tools that are dropped and then picked up again.
  144. - Will work in PBS servers
  145. - Will work as long as it starts out with the part anchored
  146. - Stores the relative CFrame as a CFrame value
  147. - Takes careful measure to reduce lag by not having a joint set off or affected by the parts offset from origin
  148. - Utilizes a recursive algorith to find all parts in the model
  149. - Will reweld on script reparent if the script is initially parented to a tool.
  150. - Welds as fast as possible
  151. ]]
  152.  
  153. -- qPerfectionWeld.lua
  154. -- Created 10/6/2014
  155. -- Author: Quenty
  156. -- Version 1.0.3
  157.  
  158. -- Updated 10/14/2014 - Updated to 1.0.1
  159. --- Bug fix with existing ROBLOX welds ? Repro by asimo3089
  160.  
  161. -- Updated 10/14/2014 - Updated to 1.0.2
  162. --- Fixed bug fix.
  163.  
  164. -- Updated 10/14/2014 - Updated to 1.0.3
  165. --- Now handles joints semi-acceptably. May be rather hacky with some joints. :/
  166.  
  167. local NEVER_BREAK_JOINTS = false -- If you set this to true it will never break joints (this can create some welding issues, but can save stuff like hinges).
  168.  
  169.  
  170. local function CallOnChildren(Instance, FunctionToCall)
  171. -- Calls a function on each of the children of a certain object, using recursion.
  172.  
  173. FunctionToCall(Instance)
  174.  
  175. for _, Child in next, Instance:GetChildren() do
  176. CallOnChildren(Child, FunctionToCall)
  177. end
  178. end
  179.  
  180. local function GetNearestParent(Instance, ClassName)
  181. -- Returns the nearest parent of a certain class, or returns nil
  182.  
  183. local Ancestor = Instance
  184. repeat
  185. Ancestor = Ancestor.Parent
  186. if Ancestor == nil then
  187. return nil
  188. end
  189. until Ancestor:IsA(ClassName)
  190.  
  191. return Ancestor
  192. end
  193.  
  194. local function GetBricks(StartInstance)
  195. local List = {}
  196.  
  197. -- if StartInstance:IsA("BasePart") then
  198. -- List[#List+1] = StartInstance
  199. -- end
  200.  
  201. CallOnChildren(StartInstance, function(Item)
  202. if Item:IsA("BasePart") then
  203. List[#List+1] = Item;
  204. end
  205. end)
  206.  
  207. return List
  208. end
  209.  
  210. local function Modify(Instance, Values)
  211. -- Modifies an Instance by using a table.
  212.  
  213. assert(type(Values) == "table", "Values is not a table");
  214.  
  215. for Index, Value in next, Values do
  216. if type(Index) == "number" then
  217. Value.Parent = Instance
  218. else
  219. Instance[Index] = Value
  220. end
  221. end
  222. return Instance
  223. end
  224.  
  225. local function Make(ClassType, Properties)
  226. -- Using a syntax hack to create a nice way to Make new items.
  227.  
  228. return Modify(Instance.new(ClassType), Properties)
  229. end
  230.  
  231. local Surfaces = {"TopSurface", "BottomSurface", "LeftSurface", "RightSurface", "FrontSurface", "BackSurface"}
  232. local HingSurfaces = {"Hinge", "Motor", "SteppingMotor"}
  233.  
  234. local function HasWheelJoint(Part)
  235. for _, SurfaceName in pairs(Surfaces) do
  236. for _, HingSurfaceName in pairs(HingSurfaces) do
  237. if Part[SurfaceName].Name == HingSurfaceName then
  238. return true
  239. end
  240. end
  241. end
  242.  
  243. return false
  244. end
  245.  
  246. local function ShouldBreakJoints(Part)
  247. --- We do not want to break joints of wheels/hinges. This takes the utmost care to not do this. There are
  248. -- definitely some edge cases.
  249.  
  250. if NEVER_BREAK_JOINTS then
  251. return false
  252. end
  253.  
  254. if HasWheelJoint(Part) then
  255. return false
  256. end
  257.  
  258. local Connected = Part:GetConnectedParts()
  259.  
  260. if #Connected == 1 then
  261. return false
  262. end
  263.  
  264. for _, Item in pairs(Connected) do
  265. if HasWheelJoint(Item) then
  266. return false
  267. elseif not Item:IsDescendantOf(script.Parent) then
  268. return false
  269. end
  270. end
  271.  
  272. return true
  273. end
  274.  
  275. local function WeldTogether(Part0, Part1, JointType, WeldParent)
  276. --- Weld's 2 parts together
  277. -- @param Part0 The first part
  278. -- @param Part1 The second part (Dependent part most of the time).
  279. -- @param [JointType] The type of joint. Defaults to weld.
  280. -- @param [WeldParent] Parent of the weld, Defaults to Part0 (so GC is better).
  281. -- @return The weld created.
  282.  
  283. JointType = JointType or "Weld"
  284. local RelativeValue = Part1:FindFirstChild("qRelativeCFrameWeldValue")
  285.  
  286. local NewWeld = Part1:FindFirstChild("qCFrameWeldThingy") or Instance.new(JointType)
  287. Modify(NewWeld, {
  288. Name = "qCFrameWeldThingy";
  289. Part0 = Part0;
  290. Part1 = Part1;
  291. C0 = CFrame.new();--Part0.CFrame:inverse();
  292. C1 = RelativeValue and RelativeValue.Value or Part1.CFrame:toObjectSpace(Part0.CFrame); --Part1.CFrame:inverse() * Part0.CFrame;-- Part1.CFrame:inverse();
  293. Parent = Part1;
  294. })
  295.  
  296. if not RelativeValue then
  297. RelativeValue = Make("CFrameValue", {
  298. Parent = Part1;
  299. Name = "qRelativeCFrameWeldValue";
  300. Archivable = true;
  301. Value = NewWeld.C1;
  302. })
  303. end
  304.  
  305. return NewWeld
  306. end
  307.  
  308. local function WeldParts(Parts, MainPart, JointType, DoNotUnanchor)
  309. -- @param Parts The Parts to weld. Should be anchored to prevent really horrible results.
  310. -- @param MainPart The part to weld the model to (can be in the model).
  311. -- @param [JointType] The type of joint. Defaults to weld.
  312. -- @parm DoNotUnanchor Boolean, if true, will not unachor the model after cmopletion.
  313.  
  314. for _, Part in pairs(Parts) do
  315. if ShouldBreakJoints(Part) then
  316. Part:BreakJoints()
  317. end
  318. end
  319.  
  320. for _, Part in pairs(Parts) do
  321. if Part ~= MainPart then
  322. WeldTogether(MainPart, Part, JointType, MainPart)
  323. end
  324. end
  325.  
  326. if not DoNotUnanchor then
  327. for _, Part in pairs(Parts) do
  328. Part.Anchored = false
  329. end
  330. MainPart.Anchored = false
  331. end
  332. end
  333.  
  334. local function PerfectionWeld()
  335. local Tool = GetNearestParent(script, "Tool")
  336.  
  337. local Parts = GetBricks(script.Parent)
  338. local PrimaryPart = Tool and Tool:FindFirstChild("Handle") and Tool.Handle:IsA("BasePart") and Tool.Handle or script.Parent:IsA("Model") and script.Parent.PrimaryPart or Parts[1]
  339.  
  340. if PrimaryPart then
  341. WeldParts(Parts, PrimaryPart, "Weld", false)
  342. else
  343. warn("qWeld - Unable to weld part")
  344. end
  345.  
  346. return Tool
  347. end
  348.  
  349. local Tool = PerfectionWeld()
  350.  
  351.  
  352. if Tool and script.ClassName == "Script" then
  353. --- Don't bother with local scripts
  354.  
  355. script.Parent.AncestryChanged:connect(function()
  356. PerfectionWeld()
  357. end)
  358. end
  359.  
  360. -- Created by Quenty (@Quenty, follow me on twitter).
  361.  
  362. end))
  363. for i,v in pairs(mas:GetChildren()) do
  364. v.Parent = workspace
  365. pcall(function() v:MakeJoints() end)
  366. end
  367. mas:Destroy()
  368. for i,v in pairs(cors) do
  369. spawn(function()
  370. pcall(v)
  371. end)
  372. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement