Difficulty replacing Region3 of water with air (for removing puddles)

Good afternoon,

I am trying to replace water (within a designated Region3) with air

However, my script doesn’t appear to be functioning despite no errors

I have attemped to see if my Region3 is loading correctly, so I visualised it using this thread [ How would i visualize a region3 - #2 by Dev_Ryan ] - which works, however still nothing happens & the water is still not replaced.

Does anyone have any understanding of why this isn’t working?

-- [LOCAL SCRIPT]
-- This essentially just determines mouse position, this is then sent to the server script (see below)
		local unitRay = mouse.UnitRay
		local ray = Ray.new(unitRay.Origin,unitRay.Direction * 1000)
		local _,blob = workspace:FindPartOnRayWithIgnoreList(ray,{char;})
-- [SERVER SCRIPT]
 -- Params
		local materialToReplace = Enum.Material.Water
		local replacementMaterial = Enum.Material.Air

		local min = Vector3.new(blob.X-4, blob.Y-4, blob.Z-4)
		local max= Vector3.new(blob.X+4, blob.Y+4, blob.Z+4)

		local Reigon = Region3.new(min,max)
		Reigon:ExpandToGrid(4)

 -- Replace
		workspace.Terrain:ReplaceMaterial(Reigon,4,materialToReplace, replacementMaterial)

 -- Reigon Visualizer 
		local regionVisualizer = Instance.new("Part")
		regionVisualizer.Name = "rV"
		regionVisualizer.Anchored = true
		regionVisualizer.Size = Reigon.Size
		regionVisualizer.CFrame = Reigon.CFrame
		regionVisualizer.Parent = workspace
		regionVisualizer.Transparency = 0.9

Please see attached video for reference : https://gyazo.com/ff0b5efb65be8aa3f1177da9c37a2f5f

This is critical for my game, can anyone advise please?

Solution found : Min/Max was just too small, I changed the size from 4x4x4 to 6x6x6 and it works

local min = Vector3.new(blob.X-6, blob.Y-6, blob.Z-6)|
local max= Vector3.new(blob.X+6, blob.Y+6, blob.Z+6)|

Please see attached for reference


: https://gyazo.com/0635ff9eda3d91949940061fd33dba44

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.