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