Advertisement
doryna2281337

Untitled

Aug 31st, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.00 KB | None | 0 0
  1. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  2. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  3. do
  4. print("FE Compatibility code by Mokiros")
  5. script.Parent = Player.Character
  6.  
  7. --RemoteEvent for communicating
  8. local Event = Instance.new("RemoteEvent")
  9. Event.Name = "UserInput_Event"
  10.  
  11. --Fake event to make stuff like Mouse.KeyDown work
  12. local function fakeEvent()
  13. local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
  14. t.connect = t.Connect
  15. return t
  16. end
  17.  
  18. --Creating fake input objects with fake variables
  19. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  20. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  21. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  22. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  23. end}
  24. --Merged 2 functions into one by checking amount of arguments
  25. CAS.UnbindAction = CAS.BindAction
  26.  
  27. --This function will trigger the events that have been :Connect()'ed
  28. local function te(self,ev,...)
  29. local t = m[ev]
  30. if t and t._fakeEvent and t.Function then
  31. t.Function(...)
  32. end
  33. end
  34. m.TrigEvent = te
  35. UIS.TrigEvent = te
  36.  
  37. Event.OnServerEvent:Connect(function(plr,io)
  38. if plr~=Player then return end
  39. if io.isMouse then
  40. m.Target = io.Target
  41. m.Hit = io.Hit
  42. else
  43. local b = io.UserInputState == Enum.UserInputState.Begin
  44. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  45. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  46. end
  47. for _,t in pairs(CAS.Actions) do
  48. for _,k in pairs(t.Keys) do
  49. if k==io.KeyCode then
  50. t.Function(t.Name,io.UserInputState,io)
  51. end
  52. end
  53. end
  54. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  55. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  56. end
  57. end)
  58. Event.Parent = NLS([==[
  59. local Player = game:GetService("Players").LocalPlayer
  60. local Event = script:WaitForChild("UserInput_Event")
  61.  
  62. local UIS = game:GetService("UserInputService")
  63. local input = function(io,a)
  64. if a then return end
  65. --Since InputObject is a client-side instance, we create and pass table instead
  66. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
  67. end
  68. UIS.InputBegan:Connect(input)
  69. UIS.InputEnded:Connect(input)
  70.  
  71. local Mouse = Player:GetMouse()
  72. local h,t
  73. --Give the server mouse data 30 times every second, but only if the values changed
  74. --If player is not moving their mouse, client won't fire events
  75. while wait(1/30) do
  76. if h~=Mouse.Hit or t~=Mouse.Target then
  77. h,t=Mouse.Hit,Mouse.Target
  78. Event:FireServer({isMouse=true,Target=t,Hit=h})
  79. end
  80. end]==],Player.Character)
  81. Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
  82. end
  83.  
  84. --Converted with ttyyuu12345's model to script plugin v4
  85. function sandbox(var,func)
  86. local env = getfenv(func)
  87. local newenv = setmetatable({},{
  88. __index = function(self,k)
  89. if k=="script" then
  90. return var
  91. else
  92. return env[k]
  93. end
  94. end,
  95. })
  96. setfenv(func,newenv)
  97. return func
  98. end
  99. cors = {}
  100. mas = Instance.new("Model",game:GetService("Lighting"))
  101. Tool0 = Instance.new("Tool")
  102. Part1 = Instance.new("Part")
  103. SpecialMesh2 = Instance.new("SpecialMesh")
  104. Sound3 = Instance.new("Sound")
  105. LocalScript4 = Instance.new("LocalScript")
  106. BoolValue5 = Instance.new("BoolValue")
  107. ObjectValue6 = Instance.new("ObjectValue")
  108. Part7 = Instance.new("Part")
  109. Tool0.Name = "DeleteTool"
  110. Tool0.Parent = mas
  111. Tool0.TextureId = "http://www.roblox.com/asset?id=73241901"
  112. Tool0.Grip = CFrame.new(0, 0, -0.5, 0, 0, 1, 1, 0, 0, 0, 1, 0)
  113. Tool0.GripForward = Vector3.new(-1, -0, -0)
  114. Tool0.GripPos = Vector3.new(0, 0, -0.5)
  115. Tool0.GripRight = Vector3.new(0, 1, 0)
  116. Tool0.GripUp = Vector3.new(0, 0, 1)
  117. Tool0.ToolTip = "Delete"
  118. Part1.Name = "Handle"
  119. Part1.Parent = Tool0
  120. 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)
  121. Part1.Orientation = Vector3.new(-89.9499969, 0, 90)
  122. Part1.Position = Vector3.new(-19.3999996, 1.49960136, -44.498806)
  123. Part1.Rotation = Vector3.new(-89.9499969, 0, 90)
  124. Part1.Color = Color3.new(0.388235, 0.372549, 0.384314)
  125. Part1.Size = Vector3.new(1, 0.800000012, 3)
  126. Part1.BottomSurface = Enum.SurfaceType.Smooth
  127. Part1.BrickColor = BrickColor.new("Dark stone grey")
  128. Part1.Locked = true
  129. Part1.Reflectance = 0.40000000596046
  130. Part1.TopSurface = Enum.SurfaceType.Smooth
  131. Part1.brickColor = BrickColor.new("Dark stone grey")
  132. Part1.FormFactor = Enum.FormFactor.Plate
  133. Part1.formFactor = Enum.FormFactor.Plate
  134. SpecialMesh2.Parent = Part1
  135. SpecialMesh2.MeshId = "http://www.roblox.com/asset/?id=16198309"
  136. SpecialMesh2.Scale = Vector3.new(1.20000005, 1.20000005, 1.20000005)
  137. SpecialMesh2.TextureId = "http://www.roblox.com/asset/?id=16198294"
  138. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  139. Sound3.Parent = Part1
  140. Sound3.SoundId = "http://www.roblox.com/Asset/?ID=12135982"
  141. Sound3.Volume = 0.69999998807907
  142. LocalScript4.Name = "DeleteScript"
  143. LocalScript4.Parent = Tool0
  144. table.insert(cors,sandbox(LocalScript4,function()
  145. -- basic functions
  146. function waitForChild(instance, name)
  147. while not instance:FindFirstChild(name) do
  148. instance.ChildAdded:wait()
  149. end
  150. end
  151.  
  152. function waitForProperty(instance, name)
  153. while not instance[name] do
  154. instance.Changed:wait()
  155. end
  156. end
  157.  
  158. -- locals
  159. local RbxStamper = LoadLibrary("RbxStamper")
  160.  
  161. if not RbxStamper then
  162. print("Error: RbxStamper Library Load Fail! Returning")
  163. return nil
  164. end
  165.  
  166. local Tool = script.Parent
  167.  
  168. enabled = true
  169. game:GetService("ContentProvider"):Preload("rbxasset://icons/delete_sel.png")
  170.  
  171. local cluster = nil
  172.  
  173. local selectionBox
  174. local currentSelection
  175. local currentSelectionColors = {}
  176. local selectionLasso
  177.  
  178. local deleteDistance = 100
  179. local player = nil
  180.  
  181. local highlight = false
  182.  
  183. local megaClusterSelectionBox = Instance.new("Part")
  184. megaClusterSelectionBox.FormFactor = "Custom"
  185. megaClusterSelectionBox.Size = Vector3.new(4, 4, 4) -- a little thicker than 4x4x4 unit clusterpart; just so selection box is more easily seen
  186. megaClusterSelectionBox.Transparency = 1
  187. megaClusterSelectionBox.Anchored = true
  188. megaClusterSelectionBox.CanCollide = false
  189. megaClusterSelectionBox.Parent = nil
  190.  
  191. waitForProperty(game,"PlaceId")
  192. local isRestricted = (game.PlaceId == 41324860 or game.PlaceId == 129686177)
  193. local stampRegion = nil
  194. local modelToStampIn = nil
  195.  
  196. waitForChild(Tool, "AutoWedgeClusterParts")
  197. local autoWedgeClusterParts = Tool.AutoWedgeClusterParts.Value
  198.  
  199. waitForChild(Tool, "PlayerOwner")
  200. local playerOwner = Tool.PlayerOwner
  201.  
  202. -- functions
  203.  
  204. function canDeleteObject(part)
  205. -- let them delete anything that they created *or* anything on their baseplate
  206. 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))
  207. end
  208.  
  209. -- For Restricting Stamper Tool (isRestricted)
  210. function inBounds(partOrModel)
  211. if not stampRegion then return true end
  212. if not partOrModel then return true end
  213.  
  214. return RbxStamper.CanEditRegion(partOrModel, stampRegion)
  215. end
  216.  
  217. function findModel(part)
  218. if isRestricted then
  219. while part ~= nil do
  220. if part.className == "Model" and part.Name ~= modelToStampIn.Name and part.Name ~= "GarbageParts" then
  221. return part
  222. elseif part.Name == modelToStampIn.Name or part.Name == "GarbageParts" then
  223. return nil
  224. end
  225. part = part.Parent
  226. end
  227. return nil
  228.  
  229. else
  230. while part ~= game.Workspace do
  231. if part:FindFirstChild("RobloxModel") then
  232. return part
  233. end
  234. if part:IsA("Model") then
  235. return part
  236. end
  237. part = part.Parent
  238. end
  239. return nil
  240. end
  241. end
  242.  
  243. function cleanOrphanedModel(parent)
  244. if not parent then return end
  245. if parent.className == "Model" then
  246. local children = parent:GetChildren()
  247. if #children == 0 and parent.Name ~= "GarbageParts" then
  248. local oldParent = parent.Parent
  249. parent:Remove()
  250. cleanOrphanedModel(oldParent)
  251. end
  252. end
  253. end
  254.  
  255. function isChildOfMyModel(part)
  256. if not modelToStampIn then return true end
  257. if modelToStampIn:IsAncestorOf(part) then
  258. return true
  259. else return false end
  260. end
  261.  
  262. function on3dButton1Down(mouse)
  263. local part = mouse.Target
  264.  
  265. if part == nil then
  266. return
  267. elseif part:IsA("Terrain") and not isRestricted then
  268. if cluster ~= nil then
  269. local cellPos = cluster:WorldToCellPreferSolid(Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z))
  270. local autoWedgeCell = cluster.AutowedgeCell
  271. local x = cellPos.x
  272. local y = cellPos.y
  273. local z = cellPos.z
  274.  
  275. cluster:SetCell(x, y, z, 0, 0, 0)
  276.  
  277. if (autoWedgeClusterParts) then
  278.  
  279. for i = x - 1, x + 1 do
  280. for j = y - 1, y + 1 do
  281. for k = z - 1, z + 1 do
  282. autoWedgeCell(cluster,i,j,k)
  283. end
  284. end
  285. end
  286.  
  287. end
  288.  
  289. clearSelection()
  290. on3dMouseMove(mouse)
  291.  
  292. end
  293. elseif canDeleteObject(part) then
  294. local model = findModel(part)
  295. local oldParent
  296. if model then
  297. if currentSelection == model then
  298. currentSelection = nil
  299. clearSelection()
  300. end
  301. oldParent = model.Parent
  302. model:Remove()
  303. else
  304. if currentSelection == part then
  305. currentSelection = nil
  306. clearSelection()
  307. end
  308. oldParent = part.Parent
  309. part:Remove()
  310. end
  311. if isRestricted then
  312. if oldParent and oldParent ~= modelToStampIn then
  313. cleanOrphanedModel(oldParent)
  314. end
  315. else
  316. cleanOrphanedModel(oldParent)
  317. end
  318. end
  319. end
  320.  
  321. function saveSelectionColor(instance)
  322. if instance:IsA("BasePart") then
  323. currentSelectionColors[instance] = instance.BrickColor
  324. if instance.BrickColor == BrickColor.Red() then
  325. instance.BrickColor = BrickColor.new("Really red")
  326. else
  327. instance.BrickColor = BrickColor.Red()
  328. end
  329. end
  330. end
  331.  
  332. function setSelection(partOrModel)
  333. if partOrModel ~= currentSelection then
  334. clearSelection()
  335. currentSelection = partOrModel
  336. selectionBox.Adornee = currentSelection
  337. end
  338. end
  339.  
  340. function clearSelection()
  341. if currentSelection ~= nil then
  342. for part, color in pairs(currentSelectionColors) do
  343. part.BrickColor = color
  344. end
  345. selectionBox.Adornee = nil
  346. end
  347. currentSelectionColors = {}
  348. if currentSelection then currentSelection = nil end
  349. if selectionBox then selectionBox.Adornee = nil end
  350. megaClusterSelectionBox.Parent = nil
  351. end
  352.  
  353.  
  354. function on3dMouseMove(mouse)
  355. local part = mouse.Target
  356.  
  357. if not part then
  358. clearSelection()
  359. return
  360. elseif part:IsA("Terrain") and not isRestricted then
  361. if not cluster then cluster = game.Workspace.Terrain end
  362. local hitCell = cluster:WorldToCellPreferSolid(mouse.Hit.p)
  363. if cluster:GetCell(hitCell.x, hitCell.y, hitCell.z).Value > 0 then
  364. megaClusterSelectionBox.CFrame = CFrame.new(cluster:CellCenterToWorld(hitCell.x, hitCell.y, hitCell.z))
  365.  
  366. if isRestricted then
  367. megaClusterSelectionBox.Parent = game.Workspace.BaseplateBumpers
  368. else
  369. megaClusterSelectionBox.Parent = game.Workspace
  370. end
  371.  
  372. selectionBox.Adornee = megaClusterSelectionBox
  373. currentSelection = nil -- necessary so selection box can transition between terrain and non-terrain smoothly
  374. else
  375. clearSelection()
  376. return
  377. end
  378. elseif canDeleteObject(part) then
  379. local model = findModel(part)
  380. if model then
  381. selectionBox.Color = BrickColor.Red()
  382. setSelection(model)
  383. else
  384. selectionBox.Color = BrickColor.Red()
  385. setSelection(part)
  386. end
  387. else
  388. clearSelection()
  389. end
  390. end
  391.  
  392. local equipCount = 0
  393. function onEquippedLocal(mouse)
  394. equipCount = equipCount + 1
  395. local val = equipCount
  396.  
  397. if isRestricted then
  398. waitForChild(game.Workspace, "BuildingAreas")
  399. if val ~= equipCount then
  400. return
  401. end
  402. end
  403.  
  404. mouse.TargetFilter = megaClusterSelectionBox
  405.  
  406. local character = script.Parent.Parent
  407. player = game.Players:GetPlayerFromCharacter(character)
  408.  
  409. if not player then return end
  410.  
  411. if playerOwner.Value and playerOwner.Value ~= player then return end
  412. playerOwner.Value = player
  413.  
  414. guiMain = Instance.new("ScreenGui")
  415. guiMain.Parent = player.PlayerGui
  416.  
  417. mouse.Button1Down:connect(function() on3dButton1Down(mouse) end)
  418. mouse.Move:connect(function() on3dMouseMove(mouse) end)
  419. mouse.Icon = "http://www.roblox.com/asset?id=72539748"
  420.  
  421. selectionBox = Instance.new("SelectionBox")
  422. selectionBox.Name = "Model Delete Selection"
  423. selectionBox.Color = BrickColor.Red()
  424. selectionBox.Adornee = nil
  425. selectionBox.Parent = player.PlayerGui
  426.  
  427. selectionLasso = Instance.new("SelectionPartLasso")
  428. selectionLasso.Name = "Model Delete Lasso"
  429. selectionLasso.Humanoid = character.Humanoid
  430. selectionLasso.archivable = false
  431. selectionLasso.Visible = true
  432. selectionLasso.Parent = game.workspace
  433. selectionLasso.Color = BrickColor.Red()
  434.  
  435. highlight = true
  436. end
  437.  
  438. function onUnequippedLocal()
  439. highlight = false
  440. if selectionBox then
  441. clearSelection()
  442. selectionBox:Remove()
  443. end
  444. if selectionLasso then selectionLasso:Remove() end
  445. end
  446. ----------------------------------------------------------------------------------------
  447. if isRestricted then -- setup our variables
  448. waitForChild(game,"Workspace")
  449. waitForChild(game.Workspace, "BuildingAreas")
  450. waitForChild(game.Workspace.BuildingAreas, "Area1")
  451. waitForChild(game.Workspace.BuildingAreas, "Area9") -- all areas loaded
  452.  
  453. while not modelToStampIn do -- check for build area until we find one
  454. local buildAreas = game.Workspace.BuildingAreas:GetChildren()
  455. for i = 1, #buildAreas do
  456. if buildAreas[i]:IsA("Model") then
  457. waitForChild(buildAreas[i],"Player")
  458. if buildAreas[i].Player.Value == owner.Name then
  459. waitForChild(buildAreas[i],"PlayerArea")
  460. modelToStampIn = buildAreas[i].PlayerArea
  461. break
  462. end
  463. end
  464. end
  465. if not modelToStampIn then
  466. wait(0.5)
  467. end
  468. end
  469.  
  470. local lowPos = modelToStampIn.Parent:FindFirstChild("LowPos")
  471. local highPos = modelToStampIn.Parent:FindFirstChild("HighPos")
  472. if not lowPos or highPos then
  473. wait(0.5)
  474. lowPos = modelToStampIn.Parent:FindFirstChild("LowPos")
  475. highPos = modelToStampIn.Parent:FindFirstChild("HighPos")
  476. end
  477. while lowPos.Value == Vector3.new(0,0,0) or highPos.Value == Vector3.new(0,0,0) do
  478. wait(0.5)
  479. end -- tool doesn't work until these are defined
  480.  
  481. stampRegion = Region3.new(lowPos.Value, highPos.Value) -- this is where we can stamp
  482. end
  483.  
  484. Tool.Equipped:connect(onEquippedLocal)
  485. Tool.Unequipped:connect(onUnequippedLocal)
  486.  
  487. end))
  488. BoolValue5.Name = "AutoWedgeClusterParts"
  489. BoolValue5.Parent = Tool0
  490. ObjectValue6.Name = "PlayerOwner"
  491. ObjectValue6.Parent = Tool0
  492. Part7.Parent = Tool0
  493. Part7.CFrame = CFrame.new(-21, 0.500001013, -31, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  494. Part7.Position = Vector3.new(-21, 0.500001013, -31)
  495. Part7.Size = Vector3.new(4, 1, 2)
  496. Part7.BottomSurface = Enum.SurfaceType.Smooth
  497. Part7.TopSurface = Enum.SurfaceType.Smooth
  498. for i,v in pairs(mas:GetChildren()) do
  499. v.Parent = owner.Backpack
  500. pcall(function() v:MakeJoints() end)
  501. end
  502. mas:Destroy()
  503. for i,v in pairs(cors) do
  504. spawn(function()
  505. pcall(v)
  506. end)
  507. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement