Advertisement
doryna2281337

Untitled

Aug 31st, 2019
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.15 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. Tool0 = Instance.new("Tool")
  19. Part1 = Instance.new("Part")
  20. SpecialMesh2 = Instance.new("SpecialMesh")
  21. Sound3 = Instance.new("Sound")
  22. LocalScript4 = Instance.new("LocalScript")
  23. BoolValue5 = Instance.new("BoolValue")
  24. ObjectValue6 = Instance.new("ObjectValue")
  25. Part7 = Instance.new("Part")
  26. Tool0.Name = "DeleteTool"
  27. Tool0.Parent = mas
  28. Tool0.TextureId = "http://www.roblox.com/asset?id=73241901"
  29. Tool0.Grip = CFrame.new(0, 0, -0.5, 0, 0, 1, 1, 0, 0, 0, 1, 0)
  30. Tool0.GripForward = Vector3.new(-1, -0, -0)
  31. Tool0.GripPos = Vector3.new(0, 0, -0.5)
  32. Tool0.GripRight = Vector3.new(0, 1, 0)
  33. Tool0.GripUp = Vector3.new(0, 0, 1)
  34. Tool0.ToolTip = "Delete"
  35. Part1.Name = "Handle"
  36. Part1.Parent = Tool0
  37. Part1.CFrame = CFrame.new(-19.3999996, 1.49960136, -44.498806, 4.14846184e-08, -1.00000024, -4.36557457e-11, 0.000796274224, 0, 0.999999642, -1, -1.54741002e-08, 0.000796274573)
  38. Part1.Orientation = Vector3.new(-89.9499969, 0, 90)
  39. Part1.Position = Vector3.new(-19.3999996, 1.49960136, -44.498806)
  40. Part1.Rotation = Vector3.new(-89.9499969, 0, 90)
  41. Part1.Color = Color3.new(0.388235, 0.372549, 0.384314)
  42. Part1.Size = Vector3.new(1, 0.800000012, 3)
  43. Part1.BottomSurface = Enum.SurfaceType.Smooth
  44. Part1.BrickColor = BrickColor.new("Dark stone grey")
  45. Part1.Locked = true
  46. Part1.Reflectance = 0.40000000596046
  47. Part1.TopSurface = Enum.SurfaceType.Smooth
  48. Part1.brickColor = BrickColor.new("Dark stone grey")
  49. Part1.FormFactor = Enum.FormFactor.Plate
  50. Part1.formFactor = Enum.FormFactor.Plate
  51. SpecialMesh2.Parent = Part1
  52. SpecialMesh2.MeshId = "http://www.roblox.com/asset/?id=16198309"
  53. SpecialMesh2.Scale = Vector3.new(1.20000005, 1.20000005, 1.20000005)
  54. SpecialMesh2.TextureId = "http://www.roblox.com/asset/?id=16198294"
  55. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  56. Sound3.Parent = Part1
  57. Sound3.SoundId = "http://www.roblox.com/Asset/?ID=12135982"
  58. Sound3.Volume = 0.69999998807907
  59. LocalScript4.Name = "DeleteScript"
  60. LocalScript4.Parent = Tool0
  61. table.insert(cors,sandbox(LocalScript4,function()
  62. -- basic functions
  63. function waitForChild(instance, name)
  64. while not instance:FindFirstChild(name) do
  65. instance.ChildAdded:wait()
  66. end
  67. end
  68.  
  69. function waitForProperty(instance, name)
  70. while not instance[name] do
  71. instance.Changed:wait()
  72. end
  73. end
  74.  
  75. -- locals
  76. local RbxStamper = LoadLibrary("RbxStamper")
  77.  
  78. if not RbxStamper then
  79. print("Error: RbxStamper Library Load Fail! Returning")
  80. return nil
  81. end
  82.  
  83. local Tool = script.Parent
  84.  
  85. enabled = true
  86. game:GetService("ContentProvider"):Preload("rbxasset://icons/delete_sel.png")
  87.  
  88. local cluster = nil
  89.  
  90. local selectionBox
  91. local currentSelection
  92. local currentSelectionColors = {}
  93. local selectionLasso
  94.  
  95. local deleteDistance = 100
  96. local player = nil
  97.  
  98. local highlight = false
  99.  
  100. local megaClusterSelectionBox = Instance.new("Part")
  101. megaClusterSelectionBox.FormFactor = "Custom"
  102. megaClusterSelectionBox.Size = Vector3.new(4, 4, 4) -- a little thicker than 4x4x4 unit clusterpart; just so selection box is more easily seen
  103. megaClusterSelectionBox.Transparency = 1
  104. megaClusterSelectionBox.Anchored = true
  105. megaClusterSelectionBox.CanCollide = false
  106. megaClusterSelectionBox.Parent = nil
  107.  
  108. waitForProperty(game,"PlaceId")
  109. local isRestricted = (game.PlaceId == 41324860 or game.PlaceId == 129686177)
  110. local stampRegion = nil
  111. local modelToStampIn = nil
  112.  
  113. waitForChild(Tool, "AutoWedgeClusterParts")
  114. local autoWedgeClusterParts = Tool.AutoWedgeClusterParts.Value
  115.  
  116. waitForChild(Tool, "PlayerOwner")
  117. local playerOwner = Tool.PlayerOwner
  118.  
  119. -- functions
  120.  
  121. function canDeleteObject(part)
  122. -- let them delete anything that they created *or* anything on their baseplate
  123. return part and not (part.Locked) and part:IsA("BasePart") and (part.Position - Tool.Parent.Head.Position).Magnitude < deleteDistance and (isChildOfMyModel(part) or inBounds(part))
  124. end
  125.  
  126. -- For Restricting Stamper Tool (isRestricted)
  127. function inBounds(partOrModel)
  128. if not stampRegion then return true end
  129. if not partOrModel then return true end
  130.  
  131. return RbxStamper.CanEditRegion(partOrModel, stampRegion)
  132. end
  133.  
  134. function findModel(part)
  135. if isRestricted then
  136. while part ~= nil do
  137. if part.className == "Model" and part.Name ~= modelToStampIn.Name and part.Name ~= "GarbageParts" then
  138. return part
  139. elseif part.Name == modelToStampIn.Name or part.Name == "GarbageParts" then
  140. return nil
  141. end
  142. part = part.Parent
  143. end
  144. return nil
  145.  
  146. else
  147. while part ~= game.Workspace do
  148. if part:FindFirstChild("RobloxModel") then
  149. return part
  150. end
  151. if part:IsA("Model") then
  152. return part
  153. end
  154. part = part.Parent
  155. end
  156. return nil
  157. end
  158. end
  159.  
  160. function cleanOrphanedModel(parent)
  161. if not parent then return end
  162. if parent.className == "Model" then
  163. local children = parent:GetChildren()
  164. if #children == 0 and parent.Name ~= "GarbageParts" then
  165. local oldParent = parent.Parent
  166. parent:Remove()
  167. cleanOrphanedModel(oldParent)
  168. end
  169. end
  170. end
  171.  
  172. function isChildOfMyModel(part)
  173. if not modelToStampIn then return true end
  174. if modelToStampIn:IsAncestorOf(part) then
  175. return true
  176. else return false end
  177. end
  178.  
  179. function on3dButton1Down(mouse)
  180. local part = mouse.Target
  181.  
  182. if part == nil then
  183. return
  184. elseif part:IsA("Terrain") and not isRestricted then
  185. if cluster ~= nil then
  186. local cellPos = cluster:WorldToCellPreferSolid(Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z))
  187. local autoWedgeCell = cluster.AutowedgeCell
  188. local x = cellPos.x
  189. local y = cellPos.y
  190. local z = cellPos.z
  191.  
  192. cluster:SetCell(x, y, z, 0, 0, 0)
  193.  
  194. if (autoWedgeClusterParts) then
  195.  
  196. for i = x - 1, x + 1 do
  197. for j = y - 1, y + 1 do
  198. for k = z - 1, z + 1 do
  199. autoWedgeCell(cluster,i,j,k)
  200. end
  201. end
  202. end
  203.  
  204. end
  205.  
  206. clearSelection()
  207. on3dMouseMove(mouse)
  208.  
  209. end
  210. elseif canDeleteObject(part) then
  211. local model = findModel(part)
  212. local oldParent
  213. if model then
  214. if currentSelection == model then
  215. currentSelection = nil
  216. clearSelection()
  217. end
  218. oldParent = model.Parent
  219. model:Remove()
  220. else
  221. if currentSelection == part then
  222. currentSelection = nil
  223. clearSelection()
  224. end
  225. oldParent = part.Parent
  226. part:Remove()
  227. end
  228. if isRestricted then
  229. if oldParent and oldParent ~= modelToStampIn then
  230. cleanOrphanedModel(oldParent)
  231. end
  232. else
  233. cleanOrphanedModel(oldParent)
  234. end
  235. end
  236. end
  237.  
  238. function saveSelectionColor(instance)
  239. if instance:IsA("BasePart") then
  240. currentSelectionColors[instance] = instance.BrickColor
  241. if instance.BrickColor == BrickColor.Red() then
  242. instance.BrickColor = BrickColor.new("Really red")
  243. else
  244. instance.BrickColor = BrickColor.Red()
  245. end
  246. end
  247. end
  248.  
  249. function setSelection(partOrModel)
  250. if partOrModel ~= currentSelection then
  251. clearSelection()
  252. currentSelection = partOrModel
  253. selectionBox.Adornee = currentSelection
  254. end
  255. end
  256.  
  257. function clearSelection()
  258. if currentSelection ~= nil then
  259. for part, color in pairs(currentSelectionColors) do
  260. part.BrickColor = color
  261. end
  262. selectionBox.Adornee = nil
  263. end
  264. currentSelectionColors = {}
  265. if currentSelection then currentSelection = nil end
  266. if selectionBox then selectionBox.Adornee = nil end
  267. megaClusterSelectionBox.Parent = nil
  268. end
  269.  
  270.  
  271. function on3dMouseMove(mouse)
  272. local part = mouse.Target
  273.  
  274. if not part then
  275. clearSelection()
  276. return
  277. elseif part:IsA("Terrain") and not isRestricted then
  278. if not cluster then cluster = game.Workspace.Terrain end
  279. local hitCell = cluster:WorldToCellPreferSolid(mouse.Hit.p)
  280. if cluster:GetCell(hitCell.x, hitCell.y, hitCell.z).Value > 0 then
  281. megaClusterSelectionBox.CFrame = CFrame.new(cluster:CellCenterToWorld(hitCell.x, hitCell.y, hitCell.z))
  282.  
  283. if isRestricted then
  284. megaClusterSelectionBox.Parent = game.Workspace.BaseplateBumpers
  285. else
  286. megaClusterSelectionBox.Parent = game.Workspace
  287. end
  288.  
  289. selectionBox.Adornee = megaClusterSelectionBox
  290. currentSelection = nil -- necessary so selection box can transition between terrain and non-terrain smoothly
  291. else
  292. clearSelection()
  293. return
  294. end
  295. elseif canDeleteObject(part) then
  296. local model = findModel(part)
  297. if model then
  298. selectionBox.Color = BrickColor.Red()
  299. setSelection(model)
  300. else
  301. selectionBox.Color = BrickColor.Red()
  302. setSelection(part)
  303. end
  304. else
  305. clearSelection()
  306. end
  307. end
  308.  
  309. local equipCount = 0
  310. function onEquippedLocal(mouse)
  311. equipCount = equipCount + 1
  312. local val = equipCount
  313.  
  314. if isRestricted then
  315. waitForChild(game.Workspace, "BuildingAreas")
  316. if val ~= equipCount then
  317. return
  318. end
  319. end
  320.  
  321. mouse.TargetFilter = megaClusterSelectionBox
  322.  
  323. local character = script.Parent.Parent
  324. player = game.Players:GetPlayerFromCharacter(character)
  325.  
  326. if not player then return end
  327.  
  328. if playerOwner.Value and playerOwner.Value ~= player then return end
  329. playerOwner.Value = player
  330.  
  331. guiMain = Instance.new("ScreenGui")
  332. guiMain.Parent = player.PlayerGui
  333.  
  334. mouse.Button1Down:connect(function() on3dButton1Down(mouse) end)
  335. mouse.Move:connect(function() on3dMouseMove(mouse) end)
  336. mouse.Icon = "http://www.roblox.com/asset?id=72539748"
  337.  
  338. selectionBox = Instance.new("SelectionBox")
  339. selectionBox.Name = "Model Delete Selection"
  340. selectionBox.Color = BrickColor.Red()
  341. selectionBox.Adornee = nil
  342. selectionBox.Parent = player.PlayerGui
  343.  
  344. selectionLasso = Instance.new("SelectionPartLasso")
  345. selectionLasso.Name = "Model Delete Lasso"
  346. selectionLasso.Humanoid = character.Humanoid
  347. selectionLasso.archivable = false
  348. selectionLasso.Visible = true
  349. selectionLasso.Parent = game.workspace
  350. selectionLasso.Color = BrickColor.Red()
  351.  
  352. highlight = true
  353. end
  354.  
  355. function onUnequippedLocal()
  356. highlight = false
  357. if selectionBox then
  358. clearSelection()
  359. selectionBox:Remove()
  360. end
  361. if selectionLasso then selectionLasso:Remove() end
  362. end
  363. ----------------------------------------------------------------------------------------
  364. if isRestricted then -- setup our variables
  365. waitForChild(game,"Workspace")
  366. waitForChild(game.Workspace, "BuildingAreas")
  367. waitForChild(game.Workspace.BuildingAreas, "Area1")
  368. waitForChild(game.Workspace.BuildingAreas, "Area9") -- all areas loaded
  369.  
  370. while not modelToStampIn do -- check for build area until we find one
  371. local buildAreas = game.Workspace.BuildingAreas:GetChildren()
  372. for i = 1, #buildAreas do
  373. if buildAreas[i]:IsA("Model") then
  374. waitForChild(buildAreas[i],"Player")
  375. if buildAreas[i].Player.Value == game.Players.LocalPlayer.Name then
  376. waitForChild(buildAreas[i],"PlayerArea")
  377. modelToStampIn = buildAreas[i].PlayerArea
  378. break
  379. end
  380. end
  381. end
  382. if not modelToStampIn then
  383. wait(0.5)
  384. end
  385. end
  386.  
  387. local lowPos = modelToStampIn.Parent:FindFirstChild("LowPos")
  388. local highPos = modelToStampIn.Parent:FindFirstChild("HighPos")
  389. if not lowPos or highPos then
  390. wait(0.5)
  391. lowPos = modelToStampIn.Parent:FindFirstChild("LowPos")
  392. highPos = modelToStampIn.Parent:FindFirstChild("HighPos")
  393. end
  394. while lowPos.Value == Vector3.new(0,0,0) or highPos.Value == Vector3.new(0,0,0) do
  395. wait(0.5)
  396. end -- tool doesn't work until these are defined
  397.  
  398. stampRegion = Region3.new(lowPos.Value, highPos.Value) -- this is where we can stamp
  399. end
  400.  
  401. Tool.Equipped:connect(onEquippedLocal)
  402. Tool.Unequipped:connect(onUnequippedLocal)
  403.  
  404. end))
  405. BoolValue5.Name = "AutoWedgeClusterParts"
  406. BoolValue5.Parent = Tool0
  407. ObjectValue6.Name = "PlayerOwner"
  408. ObjectValue6.Parent = Tool0
  409. Part7.Parent = Tool0
  410. Part7.CFrame = CFrame.new(-21, 0.500001013, -31, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  411. Part7.Position = Vector3.new(-21, 0.500001013, -31)
  412. Part7.Size = Vector3.new(4, 1, 2)
  413. Part7.BottomSurface = Enum.SurfaceType.Smooth
  414. Part7.TopSurface = Enum.SurfaceType.Smooth
  415. for i,v in pairs(mas:GetChildren()) do
  416. v.Parent = game:GetService("Players").LocalPlayer.Backpack
  417. pcall(function() v:MakeJoints() end)
  418. end
  419. mas:Destroy()
  420. for i,v in pairs(cors) do
  421. spawn(function()
  422. pcall(v)
  423. end)
  424. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement