Hello! I need help in making a local script that has a function that runs when It’s pressing. The problem is that I want this button to ReadVoxels of the whole map and WriteVoxels to delete grass from Terrain Decoration. I’m not sure how to make it if you need more information tell me. Thx for help.
this is not possible. Once Roblox’s Engine creates the grass, it cannot be removed until the server is shut down. If you just write a simple LocalScript in a button like this:
local button = script.Parent
Button.MouseButton1Click:Connect(function()
game.Lighting.Decoration = false
end)
It will error and tell you that you are unable to change that in-game.
But If I change Voxel matierial to leafy grass from grass It will work, but I’m not sure how to do it.
Something like this:
But for all grass materials. No only with part over it.
In that case the easiest and fastest thing you can do is creating a very very big Region3 containing the whole map (In case you have multiple maps, just create a Region3 for each map) and once you have It just use workspace.Terrain:ReplaceMaterial
on that Region3.
local regionToScan = Region3.new(p1, p2)
workspace.Terrain:ReplaceMaterial(regionToScan:ExpandToGrid(4), 4, Enum.Material.Grass, Enum.Material.LeafyGrass)
If you want this change to only apply to the client, do the whole thing from a LocalScript.
Thanks for your help. but I have one more question: If this region is too large can I cut it in parts and use your code for all of them?
Yeah, you can actually do It, just create multiple Regions and then iterate through them.