You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
Basically. I want to create a system that can mine away on terrain.Pretty simple [:
What is the issue? Include screenshots / videos if possible!
Im not sure if im doing this wrong(Probs am). But why isnt my code changing the cell position to air? im using “WorldToCellPreferSolid()” to get the cell location as you will see from my code in a sec.
What exactly am i doing wrong. Shouldnt “FillBall()” set the cell position to air? or am i missunderstanding it completley?
SetCell() works to clear out terrain. But since thats deprecated its not very reliable.
Heres my code. Also before someone mentions it. I know GetMouse() is deprecated. Im only using it for testing purposes!!
local P = game.Players.LocalPlayer
local M = P:GetMouse()
M.Button1Down:Connect(function()
local Pos = workspace.Terrain:WorldToCellPreferSolid(M.Hit.Position)
workspace.Terrain:FillBall(
Pos,
5,
Enum.Material.Air
)
end)
Based on the information you provided, it seems that the issue you are facing is that the cells in the terrain are not being changed to air when you use the FillBall() function. You are using the WorldToCellPreferSolid() function to get the cell location from the mouse position, but it is not working as expected.
What you want to achieve is to create a system that can mine away terrain using code.
To solve the issue, you can try the following:
Check if the Pos variable is being set correctly by printing it to the output using print(Pos) after local Pos = workspace.Terrain:WorldToCellPreferSolid(M.Hit.Position) .
Make sure that the FillBall() function is being called with the correct arguments. The first argument is the center of the ball, the second argument is the radius, and the third argument is the material to fill the ball with. In your case, it should be Enum.Material.Air .
Try using the SetCell() function instead of FillBall() . The SetCell() function is not deprecated and can be used to set the material of a single cell.
Here is an example of how you can use the SetCell() function:
M.Button1Down:Connect(function()
local Pos = workspace.Terrain:WorldToCellPreferSolid(M.Hit.Position)
workspace.Terrain:SetCell(Pos.X, Pos.Y, Pos.Z, Enum.Material.Air)
end)
This code will set the material of the cell at Pos to air.
I hope this helps you solve the issue. Let me know if you have any further questions.