Advertisement
N0ePlox

trumpes wall

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