Advertisement
_Heh

Copy Base [ LT2 ]

Jan 28th, 2020
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.34 KB | None | 0 0
  1. --//Setting\\
  2. local RunService = game:GetService("RunService")
  3. local TargetPlayer = "PlayerName"
  4. local SlowMode = false
  5. local WipeLocal = false
  6.  
  7. local CopyStructure = true
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18. --------------------------------------
  19. if WipeLocal then
  20. for i,v in pairs(game.Workspace.PlayerModels:GetChildren()) do
  21. if v:FindFirstChild("Owner") then
  22. if v.Owner.Value == game.Players.LocalPlayer then
  23. game.ReplicatedStorage.Interaction.DestroyStructure:FireServer(v)
  24. end
  25. end
  26. end
  27. wait(0.5)
  28. end
  29.  
  30. for i,v in pairs(game.Players:GetChildren()) do
  31. if v ~= game.Players.LocalPlayer then
  32. if v.Name:find(TargetPlayer) then
  33. TargetPlayer = v
  34. break
  35. end
  36. end
  37. end
  38.  
  39. local LocalLand, TargetLand
  40.  
  41. for i,v in pairs(game.Workspace.Properties:GetChildren()) do
  42. if v:FindFirstChild("Owner") then
  43. if v.Owner.Value == TargetPlayer then
  44. TargetLand = v
  45. elseif v.Owner.Value == game.Players.LocalPlayer then
  46. LocalLand = v
  47. end
  48. end
  49. end
  50.  
  51. local CollectedTargetStructures, CollectedLocalStructures, CollectedLocalFurnitures, CollectedTargetFurnitures, CollectedLocalItems, CollectedTargetItems = {}, {}, {}, {}, {}, {}
  52. local CollectedTargetItemsCopy, CollectedTargetFurnituresCopy = {}, {}
  53. local TotalCollectedBlueprints = 0
  54. local CopyWire = false
  55. local CopyItems = false
  56. local CopyFurniture = false
  57.  
  58. if CopyStructure then
  59. for i,v in pairs(game.Workspace.PlayerModels:GetChildren()) do
  60. if v:FindFirstChild("Owner") and v.Owner.Value == TargetPlayer then
  61. if v:FindFirstChild("BuildDependentWood") and (v.Type.Value == "Structure" or v.Type.Value == "Furniture") then
  62. local Data = {}
  63. Data.WoodClass = v:FindFirstChild("BlueprintWoodClass") and v.BlueprintWoodClass.Value
  64. Data.OffSet = (v:FindFirstChild("MainCFrame") and v.MainCFrame.Value or v.PrimaryPart.CFrame) - TargetLand.OriginSquare.Position
  65. Data.BlueprintType = v.ItemName.Value
  66. table.insert(CollectedTargetStructures,Data)
  67. end
  68. end
  69. end
  70.  
  71. for i, Data in pairs(CollectedTargetStructures) do
  72. game.ReplicatedStorage.PlaceStructure.ClientPlacedBlueprint:FireServer(Data.BlueprintType, LocalLand.OriginSquare.CFrame - Vector3.new(0,20,0), game.Players.LocalPlayer)
  73.  
  74. if SlowMode and (math.random(1,2) ~= 1) then
  75. RunService.RenderStepped:Wait()
  76. end
  77. end
  78. end
  79.  
  80. function blueprintHasBeenCollected(Model)
  81. if CollectedLocalStructures[Model.Name] then
  82. for i, BlueprintModel in pairs(CollectedLocalStructures[Model.Name]) do
  83. if BlueprintModel == Model then
  84. return true
  85. end
  86. end
  87. end
  88. return false
  89. end
  90.  
  91. repeat
  92. for i,v in pairs(game.Workspace.PlayerModels:GetChildren()) do
  93. if v:FindFirstChild("Owner") and v.Owner.Value == game.Players.LocalPlayer and v:FindFirstChild("Type") and v.Type.Value == "Blueprint" and not blueprintHasBeenCollected(v) then
  94. if not CollectedLocalStructures[v.Name] then
  95. CollectedLocalStructures[v.Name] = {}
  96. end
  97. table.insert(CollectedLocalStructures[v.Name], v)
  98. TotalCollectedBlueprints = TotalCollectedBlueprints + 1
  99. end
  100. end
  101. wait()
  102. until TotalCollectedBlueprints == #CollectedTargetStructures
  103.  
  104. function SpawnStructure(Data, Blueprint)
  105. local Position = Data.OffSet + LocalLand.OriginSquare.Position
  106. game.ReplicatedStorage.PlaceStructure.ClientPlacedStructure:FireServer(Blueprint.ItemName.Value, Position, game.Players.LocalPlayer, Data.WoodClass, Blueprint, not Data.WoodClass)
  107. end
  108.  
  109. for i, Data in pairs(CollectedTargetStructures) do
  110. local Blueprint = CollectedLocalStructures[Data.BlueprintType][1]
  111. table.remove(CollectedLocalStructures[Data.BlueprintType], 1)
  112.  
  113. SpawnStructure(Data, Blueprint)
  114.  
  115. if SlowMode and (math.random(1,2) ~= 1) then
  116. RunService.RenderStepped:Wait()
  117. end
  118. end
  119.  
  120. function CreateWire(WireType, Points)
  121. local Wire = game.ReplicatedStorage.Purchasables.WireObjects[WireType]
  122.  
  123. for i,v in pairs(Points) do
  124. Points[i] = v + LocalLand.OriginSquare.Position
  125. end
  126.  
  127. game.ReplicatedStorage.PlaceStructure.ClientPlacedWire:FireServer(Wire, Points)
  128. end
  129.  
  130. if CopyWire then
  131. for i,v in pairs(game.Workspace.PlayerModels:GetChildren()) do
  132. if v:FindFirstChild("Owner") and v.Owner.Value == TargetPlayer and v:FindFirstChild("Type") and v.Type.Value == "Wire" and v:FindFirstChild("End1") then
  133. local Points = {}
  134. local PointCount = 1
  135.  
  136. table.insert(Points, (v.End1.Position - TargetLand.OriginSquare.Position))
  137.  
  138. for i,w in pairs(v:GetChildren()) do
  139. if w.Name:find("Point") then
  140. PointCount = PointCount + 1
  141. end
  142. end
  143.  
  144. for i=2, PointCount do
  145. local Point = v:FindFirstChild("Point"..tostring(i))
  146. table.insert(Points, (Point.Position - TargetLand.OriginSquare.Position))
  147. end
  148.  
  149. table.insert(Points, (v.End2.Position - TargetLand.OriginSquare.Position))
  150. CreateWire(v.ItemName.Value, Points)
  151.  
  152. if SlowMode and (math.random(1,2) ~= 1)then
  153. RunService.RenderStepped:Wait()
  154. end
  155. end
  156. end
  157. end
  158.  
  159. function isValidFurniture(Model)
  160. if Model:FindFirstChild("Type") and (Model.Type.Value == "Structure" or Model.Type.Value == "Furniture" or Model.Type.Value == "Vehicle Spot") then
  161. if Model:FindFirstChild("BuildDependentWood") or Model:FindFirstChild("PurchasedBoxItemName") then
  162. return false
  163. end
  164. return true
  165. end
  166. return false
  167. end
  168.  
  169. function Spawn(ItemName, Position)
  170. local Info = {}
  171. Info.Name = ItemName.Value
  172. Info.Type = ItemName.Name == "PurchasedBoxItemName" and ItemName or game.ReplicatedStorage.Purchasables.Structures.HardStructures.Sawmill2.Type
  173. Info.OtherInfo = game.ReplicatedStorage.Purchasables.WireObjects.Wire.OtherInfo
  174. local Points = {Position.p, Position.p}
  175. game.ReplicatedStorage.PlaceStructure.ClientPlacedWire:FireServer(Info, Points)
  176. end
  177.  
  178. if CopyFurniture then
  179. for i, Model in pairs(game.Workspace.PlayerModels:GetChildren()) do
  180. if Model:FindFirstChild("Owner") and Model.Owner.Value == TargetPlayer and isValidFurniture(Model) then
  181. local ItemName = Model:FindFirstChild("ItemName") or Model:FindFirstChild("PurchasedBoxItemName")
  182. local Position = (Model:FindFirstChild("MainCFrame") and Model.MainCFrame.Value or Model.PrimaryPart.CFrame) - TargetLand.OriginSquare.Position
  183.  
  184. if ItemName.Name == "PurchasedBoxItemName" then
  185. Spawn(ItemName, Position + LocalLand.OriginSquare.Position)
  186. else
  187. Spawn(ItemName, LocalLand.OriginSquare.CFrame - Vector3.new(0,20,0))
  188. end
  189.  
  190. local Data = {}
  191. Data.ItemName = ItemName.Value
  192. Data.OffSet = Position
  193.  
  194. table.insert(CollectedTargetFurnitures, Data)
  195.  
  196. if SlowMode and (math.random(1,2) ~= 1)then
  197. RunService.RenderStepped:Wait()
  198. end
  199. end
  200. end
  201. end
  202.  
  203. for i, v in pairs(CollectedTargetFurnitures) do
  204. table.insert(CollectedTargetFurnituresCopy,v)
  205. end
  206.  
  207. function isValidFurnitureModel(Model)
  208. for i, Data in pairs(CollectedTargetFurnitures) do
  209. if Data.ItemName == Model.ItemName.Value then
  210. table.remove(CollectedTargetFurnitures, i)
  211. return true
  212. end
  213. end
  214. return false
  215. end
  216.  
  217. repeat
  218. for i, Model in pairs(game.Workspace.PlayerModels:GetChildren()) do
  219. if Model.Name == "Wire" and Model:FindFirstChild("Owner") and Model.Owner.Value == game.Players.LocalPlayer and Model.ItemName.Value ~= "Wire" and isValidFurnitureModel(Model) then
  220. table.insert(CollectedLocalFurnitures, Model)
  221. end
  222. end
  223. wait()
  224. until #CollectedTargetFurnitures == 0
  225.  
  226. function GrabModelFromCollectedFurnitures(ItemName)
  227. for i, Model in pairs(CollectedLocalFurnitures) do
  228. if Model.ItemName.Value == ItemName then
  229. table.remove(CollectedLocalFurnitures,i)
  230. return Model
  231. end
  232. end
  233. end
  234.  
  235. for i, Data in pairs(CollectedTargetFurnituresCopy) do
  236. local Model = GrabModelFromCollectedFurnitures(Data.ItemName)
  237. local ItemName = Data.ItemName
  238. local Position = Data.OffSet + LocalLand.OriginSquare.Position
  239. game.ReplicatedStorage.PlaceStructure.ClientPlacedStructure:FireServer(ItemName,Position,game.Players.LocalPlayer,false,Model,true)
  240.  
  241. if SlowMode and (math.random(1,2) ~= 1)then
  242. RunService.RenderStepped:Wait()
  243. end
  244. end
  245.  
  246. function isValidItem(Model)
  247. if Model:FindFirstChild("Type") and (Model.Type.Value == "Structure" or Model.Type.Value == "Loose Item" or Model.Type.Value == "Tool" or Model.Type.Value == "Wire" or Model.Type.Value == "Furniture" or Model.Type.Value == "Gift") then
  248. if (Model.Type.Value == "Structure" or Model.Type.Value == "Wire" or Model.Type.Value == "Furniture") and not Model:FindFirstChild("PurchasedBoxItemName") then
  249. return false
  250. end
  251.  
  252. return true
  253. elseif not Model:FindFirstChild("Type") then
  254. if Model:FindFirstChild("ItemName") then
  255. local ItemName = Model.ItemName.Value:lower()
  256.  
  257. if ItemName:find("bob") and (ItemName:find("wob") or ItemName:find("head"))then
  258. return true
  259. end
  260. end
  261. end
  262. return false
  263. end
  264. function itemIsOnLand(Position)
  265. if (math.abs(Position.X - TargetLand.OriginSquare.Position.X) > 101 or math.abs(Position.Z - TargetLand.OriginSquare.Position.Z) > 101) then
  266. return false
  267. end
  268. for i, Square in pairs(TargetLand:GetChildren()) do
  269. if Square.Name == "Square" then
  270. if (math.abs(Position.X - Square.Position.X) < 21 and math.abs(Position.Z - Square.Position.Z) < 21) then
  271. return true
  272. end
  273. end
  274. end
  275. return false
  276. end
  277.  
  278. if CopyItems then
  279. for i, Model in pairs(game.Workspace.PlayerModels:GetChildren()) do
  280. if Model:FindFirstChild("Owner") and Model.Owner.Value == TargetPlayer and isValidItem(Model) then
  281. local ItemName = Model:FindFirstChild("ItemName") or Model:FindFirstChild("PurchasedBoxItemName")
  282. local Position = (Model:FindFirstChild("MainCFrame") and Model.MainCFrame.Value or Model.PrimaryPart.CFrame) - TargetLand.OriginSquare.Position
  283.  
  284. if itemIsOnLand((Model:FindFirstChild("MainCFrame") and Model.MainCFrame.Value or Model.PrimaryPart.CFrame).p) then
  285. Spawn(ItemName, LocalLand.OriginSquare.CFrame - Vector3.new(0,20,0))
  286.  
  287. local Data = {}
  288. Data.ItemName = ItemName.Value
  289. Data.OffSet = Position
  290.  
  291. table.insert(CollectedTargetItems, Data)
  292.  
  293. if SlowMode and (math.random(1,2) ~= 1)then
  294. RunService.RenderStepped:Wait()
  295. end
  296. end
  297. end
  298. end
  299. end
  300.  
  301. for i, v in pairs(CollectedTargetItems) do
  302. table.insert(CollectedTargetItemsCopy,v)
  303. end
  304.  
  305. function isValidItemModel(Model)
  306. for i, Data in pairs(CollectedTargetItems) do
  307. if Data.ItemName == Model.ItemName.Value then
  308. table.remove(CollectedTargetItems, i)
  309. return true
  310. end
  311. end
  312. return false
  313. end
  314. function itemHasBeenCollected(Model)
  315. for i, Data in pairs(CollectedLocalItems) do
  316. if Data.ItemName == Model.ItemName.Value then
  317. return true
  318. end
  319. end
  320. return false
  321. end
  322.  
  323. repeat
  324. for i, Model in pairs(game.Workspace.PlayerModels:GetChildren()) do
  325. if Model.Name == "Wire" and Model:FindFirstChild("Owner") and Model.Owner.Value == game.Players.LocalPlayer and (Model.ItemName.Value ~= "Wire" or (Model:FindFirstChild("ItemName") and Model.ItemName.Value == "Wire" and Model:FindFirstChild("PurchasedBoxItemName"))) and isValidItemModel(Model) and not itemHasBeenCollected(Model) then
  326. table.insert(CollectedLocalItems, Model)
  327. end
  328. end
  329. wait()
  330. until #CollectedTargetItems == 0
  331.  
  332. function GrabModelFromCollectedItems(ItemName)
  333. for i, Model in pairs(CollectedLocalItems) do
  334. if Model.ItemName.Value == ItemName then
  335. table.remove(CollectedLocalItems,i)
  336. return Model
  337. end
  338. end
  339. end
  340.  
  341. for i, Data in pairs(CollectedTargetItemsCopy) do
  342. local Model = GrabModelFromCollectedItems(Data.ItemName)
  343. local ItemName = Data.ItemName
  344. local Position = Data.OffSet + LocalLand.OriginSquare.Position
  345.  
  346. if Model:FindFirstChild("PurchasedBoxItemName") then
  347. game.ReplicatedStorage.PlaceStructure.ClientPlacedStructure:FireServer(false, Position, false, false, Model)
  348. Model.Parent = nil
  349. else
  350. game.ReplicatedStorage.PlaceStructure.ClientPlacedStructure:FireServer(ItemName,Position,game.Players.LocalPlayer,false,Model,true)
  351. end
  352.  
  353. if SlowMode and (math.random(1,2) ~= 1)then
  354. RunService.RenderStepped:Wait()
  355. end
  356. end
  357.  
  358. print("Finished Copying!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement