SHARE
TWEET

copy place script

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