Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

2 comments

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

0

or part:Destroy()

1 answer

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)

2 comments

0

Do i add this to the handle part of a tool

0

If you want, but you have to make it script.Parent.Parent on line 1 to account for that.

This discussion is preserved as it was. New answers, comments, and votes are closed.