For some reasons ReadVoxels() returns nil in my script, i’m guessing i did something wrong with region3, also it’s not a problem with my MousePos, i printed it and it is correct. My current code:
local Tool = script.Parent
local Handle = script.Parent.Handle
local MineEvent = script.Parent.Mine
MineEvent.OnServerEvent:Connect(function(Plr, MousePos)
Handle.Break:Play()
game.Workspace.Terrain:FillBall(MousePos, 6, Enum.Material.Air)
local region = Region3.new(MousePos - Vector3.new(3,3,3), MousePos + Vector3.new(3,3,3))
print(region)
local materials, occupancies = game.Workspace.Terrain:ReadVoxels(region, 4)
-- get material at the voxel at (1, 2, 3):
local theMaterial = materials[1][2][3]
print("Material: " .. theMaterial.Name) -- print the material
-- get the percentage of space occupied at that same position
local theOccupancy = occupancies[1][2][3]
print("Occupancy" .. theOccupancy)
end)