Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I found this dig script which digs terrain. How would I script it to dig a part?

Asked by 6 years ago
Edited 6 years ago

I found this dig script which digs terrain. How would I edit the code so that it digs parts which are a certain material and aren't terrain basically a part which is a sand material. For example, make a part transparency = 1 and can collide = false so the part is removed fully.

mouse = game.Players.LocalPlayer:GetMouse()
down = false
mouse.Button1Down:connect(function ()
    down = true
    mouse.Button1Up:connect(function ()
        down = false
    end)
    local recordedPosition = game.Workspace.Terrain:WorldToCellPreferSolid(mouse.Hit.p)
    local gui = script.Dig:clone()
    gui.Parent = game.Players.LocalPlayer.PlayerGui
    for i = 1,33 do
        if game.Workspace.Terrain:WorldToCellPreferSolid(mouse.Hit.p) ~= recordedPosition then
            gui:Destroy()
            return 
        end
        if down == false then
            gui:Destroy()
            return 
        end
        gui.Progress.Bar.Size = UDim2.new(0.03*i,0,1,0)
        wait()
    end
    gui:Destroy()
    game.Workspace.Terrain:SetCell(recordedPosition.X,recordedPosition.Y,recordedPosition.Z,0,0,0)
end)

Thank You and Help is appreciated

0
Setting transparency to 1 and cancollide to false does not remove the part it just makes it invisible. You should try something easier you obviously don't have the skills for this Filipalla 504 — 6y
0
or part:Destroy() aspiringstar346 8 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Note: This script is meant for a tool.

script.Parent.Activated:Connect(function(mouse)
    if mouse.Hit.Name == "Sand" then -- Just change the if to make it go with your system
        step = .1
        waitC = .1
        for i=0,1 step do
            mouse.Hit.Transparency = i
            wait(waitC)
        end
        mouse.Hit.CanCollide = false
    end
end)
0
Do i add this to the handle part of a tool aspiringstar346 8 — 6y
0
If you want, but you have to make it script.Parent.Parent on line 1 to account for that. TdaGreat04 76 — 6y
Ad

Answer this question