In my game players have the ability to toggle a ‘map filter’ on and off in order to reduce lag if they have a weaker device.
One of the things I’d like to do is toggle water on and off for each client:
water.Enabled = true
water.Enabled = false
The water in my game acts primarily as a visual enhancement rather than practical, so I don’t mind if it appears for some clients and not for others.
What’s the best way to do this?
First of all i would strongly advice against doing this sort of thing with SmoothTerrain (whilst the game is running), since you may have some major performance issues whilst ‘toggling’ the terrain.
What you’re probably looking for is TerrainFillRegion().
Basically pass in a Region3, into it and give it either a material of Enum.Material.Air or Enum.Material.Water.
local region = Region3.new(Vector3.new(0,0,-3), Vector3.new(4,4,4))
region = region:ExpandToGrid(4)
game.Workspace.Terrain:FillRegion(region, 4, Enum.Material.Slate)
(Taken from here)
I do think there is a maximum Region3 size, but IIRC it’s based on volume. If you go past the size limit, you could always split the region up a bit.
One thing you could try and do to help you, is find the point of one side of the water, and the other, and then create a Region3 from those two points (You might need to move them around so the region isn’t empty).
Alright thanks, I’ll look into this in more detail.
On Server, make Map. All water or whatever u want to toggle in a folder called Water.
W = workspace.Water
W.Parent = nil – turn off
W.Parent = workspace – turn.on
That would only work if it was part-based water. OP is looking for water toggles with terrain water, as indicated by the image (and the title - if it was for something else, I’m quite sure it’d say “best way to toggle parts” or something similar).