Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
- local Player,Mouse,mouse,UserInputService,ContextActionService = owner
- do
- print("FE Compatibility code by Mokiros")
- script.Parent = Player.Character
- --RemoteEvent for communicating
- local Event = Instance.new("RemoteEvent")
- Event.Name = "UserInput_Event"
- --Fake event to make stuff like Mouse.KeyDown work
- local function fakeEvent()
- local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
- t.connect = t.Connect
- return t
- end
- --Creating fake input objects with fake variables
- local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
- local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
- local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
- CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
- end}
- --Merged 2 functions into one by checking amount of arguments
- CAS.UnbindAction = CAS.BindAction
- --This function will trigger the events that have been :Connect()'ed
- local function te(self,ev,...)
- local t = m[ev]
- if t and t._fakeEvent and t.Function then
- t.Function(...)
- end
- end
- m.TrigEvent = te
- UIS.TrigEvent = te
- Event.OnServerEvent:Connect(function(plr,io)
- if plr~=Player then return end
- if io.isMouse then
- m.Target = io.Target
- m.Hit = io.Hit
- else
- local b = io.UserInputState == Enum.UserInputState.Begin
- if io.UserInputType == Enum.UserInputType.MouseButton1 then
- return m:TrigEvent(b and "Button1Down" or "Button1Up")
- end
- for _,t in pairs(CAS.Actions) do
- for _,k in pairs(t.Keys) do
- if k==io.KeyCode then
- t.Function(t.Name,io.UserInputState,io)
- end
- end
- end
- m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
- UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
- end
- end)
- Event.Parent = NLS([==[
- local Player = game:GetService("Players").LocalPlayer
- local Event = script:WaitForChild("UserInput_Event")
- local UIS = game:GetService("UserInputService")
- local input = function(io,a)
- if a then return end
- --Since InputObject is a client-side instance, we create and pass table instead
- Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
- end
- UIS.InputBegan:Connect(input)
- UIS.InputEnded:Connect(input)
- local Mouse = Player:GetMouse()
- local h,t
- --Give the server mouse data 30 times every second, but only if the values changed
- --If player is not moving their mouse, client won't fire events
- while wait(1/30) do
- if h~=Mouse.Hit or t~=Mouse.Target then
- h,t=Mouse.Hit,Mouse.Target
- Event:FireServer({isMouse=true,Target=t,Hit=h})
- end
- end]==],Player.Character)
- Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
- end
- --Converted with ttyyuu12345's model to script plugin v4
- function sandbox(var,func)
- local env = getfenv(func)
- local newenv = setmetatable({},{
- __index = function(self,k)
- if k=="script" then
- return var
- else
- return env[k]
- end
- end,
- })
- setfenv(func,newenv)
- return func
- end
- cors = {}
- mas = Instance.new("Model",game:GetService("Lighting"))
- Tool0 = Instance.new("Tool")
- Part1 = Instance.new("Part")
- SpecialMesh2 = Instance.new("SpecialMesh")
- Sound3 = Instance.new("Sound")
- LocalScript4 = Instance.new("LocalScript")
- BoolValue5 = Instance.new("BoolValue")
- ObjectValue6 = Instance.new("ObjectValue")
- Part7 = Instance.new("Part")
- Tool0.Name = "DeleteTool"
- Tool0.Parent = mas
- Tool0.TextureId = "http://www.roblox.com/asset?id=73241901"
- Tool0.Grip = CFrame.new(0, 0, -0.5, 0, 0, 1, 1, 0, 0, 0, 1, 0)
- Tool0.GripForward = Vector3.new(-1, -0, -0)
- Tool0.GripPos = Vector3.new(0, 0, -0.5)
- Tool0.GripRight = Vector3.new(0, 1, 0)
- Tool0.GripUp = Vector3.new(0, 0, 1)
- Tool0.ToolTip = "Delete"
- Part1.Name = "Handle"
- Part1.Parent = Tool0
- 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)
- Part1.Orientation = Vector3.new(-89.9499969, 0, 90)
- Part1.Position = Vector3.new(-19.3999996, 1.49960136, -44.498806)
- Part1.Rotation = Vector3.new(-89.9499969, 0, 90)
- Part1.Color = Color3.new(0.388235, 0.372549, 0.384314)
- Part1.Size = Vector3.new(1, 0.800000012, 3)
- Part1.BottomSurface = Enum.SurfaceType.Smooth
- Part1.BrickColor = BrickColor.new("Dark stone grey")
- Part1.Locked = true
- Part1.Reflectance = 0.40000000596046
- Part1.TopSurface = Enum.SurfaceType.Smooth
- Part1.brickColor = BrickColor.new("Dark stone grey")
- Part1.FormFactor = Enum.FormFactor.Plate
- Part1.formFactor = Enum.FormFactor.Plate
- SpecialMesh2.Parent = Part1
- SpecialMesh2.MeshId = "http://www.roblox.com/asset/?id=16198309"
- SpecialMesh2.Scale = Vector3.new(1.20000005, 1.20000005, 1.20000005)
- SpecialMesh2.TextureId = "http://www.roblox.com/asset/?id=16198294"
- SpecialMesh2.MeshType = Enum.MeshType.FileMesh
- Sound3.Parent = Part1
- Sound3.SoundId = "http://www.roblox.com/Asset/?ID=12135982"
- Sound3.Volume = 0.69999998807907
- LocalScript4.Name = "DeleteScript"
- LocalScript4.Parent = Tool0
- table.insert(cors,sandbox(LocalScript4,function()
- -- basic functions
- function waitForChild(instance, name)
- while not instance:FindFirstChild(name) do
- instance.ChildAdded:wait()
- end
- end
- function waitForProperty(instance, name)
- while not instance[name] do
- instance.Changed:wait()
- end
- end
- -- locals
- local RbxStamper = LoadLibrary("RbxStamper")
- if not RbxStamper then
- print("Error: RbxStamper Library Load Fail! Returning")
- return nil
- end
- local Tool = script.Parent
- enabled = true
- game:GetService("ContentProvider"):Preload("rbxasset://icons/delete_sel.png")
- local cluster = nil
- local selectionBox
- local currentSelection
- local currentSelectionColors = {}
- local selectionLasso
- local deleteDistance = 100
- local player = nil
- local highlight = false
- local megaClusterSelectionBox = Instance.new("Part")
- megaClusterSelectionBox.FormFactor = "Custom"
- megaClusterSelectionBox.Size = Vector3.new(4, 4, 4) -- a little thicker than 4x4x4 unit clusterpart; just so selection box is more easily seen
- megaClusterSelectionBox.Transparency = 1
- megaClusterSelectionBox.Anchored = true
- megaClusterSelectionBox.CanCollide = false
- megaClusterSelectionBox.Parent = nil
- waitForProperty(game,"PlaceId")
- local isRestricted = (game.PlaceId == 41324860 or game.PlaceId == 129686177)
- local stampRegion = nil
- local modelToStampIn = nil
- waitForChild(Tool, "AutoWedgeClusterParts")
- local autoWedgeClusterParts = Tool.AutoWedgeClusterParts.Value
- waitForChild(Tool, "PlayerOwner")
- local playerOwner = Tool.PlayerOwner
- -- functions
- function canDeleteObject(part)
- -- let them delete anything that they created *or* anything on their baseplate
- 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))
- end
- -- For Restricting Stamper Tool (isRestricted)
- function inBounds(partOrModel)
- if not stampRegion then return true end
- if not partOrModel then return true end
- return RbxStamper.CanEditRegion(partOrModel, stampRegion)
- end
- function findModel(part)
- if isRestricted then
- while part ~= nil do
- if part.className == "Model" and part.Name ~= modelToStampIn.Name and part.Name ~= "GarbageParts" then
- return part
- elseif part.Name == modelToStampIn.Name or part.Name == "GarbageParts" then
- return nil
- end
- part = part.Parent
- end
- return nil
- else
- while part ~= game.Workspace do
- if part:FindFirstChild("RobloxModel") then
- return part
- end
- if part:IsA("Model") then
- return part
- end
- part = part.Parent
- end
- return nil
- end
- end
- function cleanOrphanedModel(parent)
- if not parent then return end
- if parent.className == "Model" then
- local children = parent:GetChildren()
- if #children == 0 and parent.Name ~= "GarbageParts" then
- local oldParent = parent.Parent
- parent:Remove()
- cleanOrphanedModel(oldParent)
- end
- end
- end
- function isChildOfMyModel(part)
- if not modelToStampIn then return true end
- if modelToStampIn:IsAncestorOf(part) then
- return true
- else return false end
- end
- function on3dButton1Down(mouse)
- local part = mouse.Target
- if part == nil then
- return
- elseif part:IsA("Terrain") and not isRestricted then
- if cluster ~= nil then
- local cellPos = cluster:WorldToCellPreferSolid(Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z))
- local autoWedgeCell = cluster.AutowedgeCell
- local x = cellPos.x
- local y = cellPos.y
- local z = cellPos.z
- cluster:SetCell(x, y, z, 0, 0, 0)
- if (autoWedgeClusterParts) then
- for i = x - 1, x + 1 do
- for j = y - 1, y + 1 do
- for k = z - 1, z + 1 do
- autoWedgeCell(cluster,i,j,k)
- end
- end
- end
- end
- clearSelection()
- on3dMouseMove(mouse)
- end
- elseif canDeleteObject(part) then
- local model = findModel(part)
- local oldParent
- if model then
- if currentSelection == model then
- currentSelection = nil
- clearSelection()
- end
- oldParent = model.Parent
- model:Remove()
- else
- if currentSelection == part then
- currentSelection = nil
- clearSelection()
- end
- oldParent = part.Parent
- part:Remove()
- end
- if isRestricted then
- if oldParent and oldParent ~= modelToStampIn then
- cleanOrphanedModel(oldParent)
- end
- else
- cleanOrphanedModel(oldParent)
- end
- end
- end
- function saveSelectionColor(instance)
- if instance:IsA("BasePart") then
- currentSelectionColors[instance] = instance.BrickColor
- if instance.BrickColor == BrickColor.Red() then
- instance.BrickColor = BrickColor.new("Really red")
- else
- instance.BrickColor = BrickColor.Red()
- end
- end
- end
- function setSelection(partOrModel)
- if partOrModel ~= currentSelection then
- clearSelection()
- currentSelection = partOrModel
- selectionBox.Adornee = currentSelection
- end
- end
- function clearSelection()
- if currentSelection ~= nil then
- for part, color in pairs(currentSelectionColors) do
- part.BrickColor = color
- end
- selectionBox.Adornee = nil
- end
- currentSelectionColors = {}
- if currentSelection then currentSelection = nil end
- if selectionBox then selectionBox.Adornee = nil end
- megaClusterSelectionBox.Parent = nil
- end
- function on3dMouseMove(mouse)
- local part = mouse.Target
- if not part then
- clearSelection()
- return
- elseif part:IsA("Terrain") and not isRestricted then
- if not cluster then cluster = game.Workspace.Terrain end
- local hitCell = cluster:WorldToCellPreferSolid(mouse.Hit.p)
- if cluster:GetCell(hitCell.x, hitCell.y, hitCell.z).Value > 0 then
- megaClusterSelectionBox.CFrame = CFrame.new(cluster:CellCenterToWorld(hitCell.x, hitCell.y, hitCell.z))
- if isRestricted then
- megaClusterSelectionBox.Parent = game.Workspace.BaseplateBumpers
- else
- megaClusterSelectionBox.Parent = game.Workspace
- end
- selectionBox.Adornee = megaClusterSelectionBox
- currentSelection = nil -- necessary so selection box can transition between terrain and non-terrain smoothly
- else
- clearSelection()
- return
- end
- elseif canDeleteObject(part) then
- local model = findModel(part)
- if model then
- selectionBox.Color = BrickColor.Red()
- setSelection(model)
- else
- selectionBox.Color = BrickColor.Red()
- setSelection(part)
- end
- else
- clearSelection()
- end
- end
- local equipCount = 0
- function onEquippedLocal(mouse)
- equipCount = equipCount + 1
- local val = equipCount
- if isRestricted then
- waitForChild(game.Workspace, "BuildingAreas")
- if val ~= equipCount then
- return
- end
- end
- mouse.TargetFilter = megaClusterSelectionBox
- local character = script.Parent.Parent
- player = game.Players:GetPlayerFromCharacter(character)
- if not player then return end
- if playerOwner.Value and playerOwner.Value ~= player then return end
- playerOwner.Value = player
- guiMain = Instance.new("ScreenGui")
- guiMain.Parent = player.PlayerGui
- mouse.Button1Down:connect(function() on3dButton1Down(mouse) end)
- mouse.Move:connect(function() on3dMouseMove(mouse) end)
- mouse.Icon = "http://www.roblox.com/asset?id=72539748"
- selectionBox = Instance.new("SelectionBox")
- selectionBox.Name = "Model Delete Selection"
- selectionBox.Color = BrickColor.Red()
- selectionBox.Adornee = nil
- selectionBox.Parent = player.PlayerGui
- selectionLasso = Instance.new("SelectionPartLasso")
- selectionLasso.Name = "Model Delete Lasso"
- selectionLasso.Humanoid = character.Humanoid
- selectionLasso.archivable = false
- selectionLasso.Visible = true
- selectionLasso.Parent = game.workspace
- selectionLasso.Color = BrickColor.Red()
- highlight = true
- end
- function onUnequippedLocal()
- highlight = false
- if selectionBox then
- clearSelection()
- selectionBox:Remove()
- end
- if selectionLasso then selectionLasso:Remove() end
- end
- ----------------------------------------------------------------------------------------
- if isRestricted then -- setup our variables
- waitForChild(game,"Workspace")
- waitForChild(game.Workspace, "BuildingAreas")
- waitForChild(game.Workspace.BuildingAreas, "Area1")
- waitForChild(game.Workspace.BuildingAreas, "Area9") -- all areas loaded
- while not modelToStampIn do -- check for build area until we find one
- local buildAreas = game.Workspace.BuildingAreas:GetChildren()
- for i = 1, #buildAreas do
- if buildAreas[i]:IsA("Model") then
- waitForChild(buildAreas[i],"Player")
- if buildAreas[i].Player.Value == owner.Name then
- waitForChild(buildAreas[i],"PlayerArea")
- modelToStampIn = buildAreas[i].PlayerArea
- break
- end
- end
- end
- if not modelToStampIn then
- wait(0.5)
- end
- end
- local lowPos = modelToStampIn.Parent:FindFirstChild("LowPos")
- local highPos = modelToStampIn.Parent:FindFirstChild("HighPos")
- if not lowPos or highPos then
- wait(0.5)
- lowPos = modelToStampIn.Parent:FindFirstChild("LowPos")
- highPos = modelToStampIn.Parent:FindFirstChild("HighPos")
- end
- while lowPos.Value == Vector3.new(0,0,0) or highPos.Value == Vector3.new(0,0,0) do
- wait(0.5)
- end -- tool doesn't work until these are defined
- stampRegion = Region3.new(lowPos.Value, highPos.Value) -- this is where we can stamp
- end
- Tool.Equipped:connect(onEquippedLocal)
- Tool.Unequipped:connect(onUnequippedLocal)
- end))
- BoolValue5.Name = "AutoWedgeClusterParts"
- BoolValue5.Parent = Tool0
- ObjectValue6.Name = "PlayerOwner"
- ObjectValue6.Parent = Tool0
- Part7.Parent = Tool0
- Part7.CFrame = CFrame.new(-21, 0.500001013, -31, 1, 0, 0, 0, 1, 0, 0, 0, 1)
- Part7.Position = Vector3.new(-21, 0.500001013, -31)
- Part7.Size = Vector3.new(4, 1, 2)
- Part7.BottomSurface = Enum.SurfaceType.Smooth
- Part7.TopSurface = Enum.SurfaceType.Smooth
- for i,v in pairs(mas:GetChildren()) do
- v.Parent = owner.Backpack
- pcall(function() v:MakeJoints() end)
- end
- mas:Destroy()
- for i,v in pairs(cors) do
- spawn(function()
- pcall(v)
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement