I’m working on a building system for my game, and I want structures like Floors to replace the terrain material under them from Grass to Mud.
The structures have a primary part that covers their entire model like this.
I wanna use this primary part to replace any grass under itself to mud, so after looking at some docs and examples, I’ve came up with this code, but it has no effect on the terrain what so ever.
local part = script.Parent; local StudsUnder = 1; local region = Region3.new((part.Position - Vector3.new(0, StudsUnder, 0)) - (part.Size/2), (part.Position - Vector3.new(0, StudsUnder, 0)) + (part.Size/2)); workspace.Terrain:ReplaceMaterial(region, 4, Enum.Material.Grass, Enum.Material.Mud);
I should probably note that I don’t understand regions very well so I’m not sure if the region I’ve came up with is even correct.
Could you guys tell me how you would go about this?