I want to make a script that when you click on terrain it digs a small little crator.
My issue is that im not that good at scripting so i need help with this because im preatty dumb so i don’t know how to script good i can script but im not a pro.
accualy i have tried one thing is to try using ReplaceMaterial
but i dont know how to properly use it
game.Workspace.Terrain:FillBall(Position,Size, Enum.Material.Air)
1 Like
--ok i got it
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)
1 Like