Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I use FillRegion for making water terrain?

Asked by 7 years ago

I'm trying to fill a very large region with water, and I've been looking through the wiki and stuff, and it's supposed to go FillRegion(Region3, resolution, material) and I have no idea wtf resolution is for (I think it's supposed to be a number). My code is

game.Workspace.Terrain:FillRegion(Region3.new(Vector3.new(1232.5, -340.5, 517.5), Vector3.new(-816.5, 302.5, -1531.5)), 0, Water)

I put it in the console, and it then it says "Argument 3 missing or nil". Please help me, it lags a ton when doing terrain manually.

1 answer

Log in to vote
0
Answered by
RayCurse 1518 Moderation Voter
7 years ago
Edited 7 years ago

Your code is throwing an error because your third argument in your call to FillRegion() is invalid. The third argument is supposed to be a Material enumeration.

The Region3 value is also incorrect because it has to be aligned with the voxel grid. A voxel is basically a 3d pixel and can be described as a cube. Roblox uses a voxel system for their terrain by basically filling these cubes with a material. Because you are filling terrain, your Region3 has to be aligned with the 3D voxel grid. This is what the function ExpandToGrid() is for.

The ExpandToGrid() function has one parameter which is the resolution of the grid to expand to.

Resolution here refers to the resolution of the voxel grid that Roblox uses for terrain. You can think of this as the length of each cube. This parameter must always be set to four when dealing with terrain no matter what because that is the only resolution that is supported at this time. The only reason Roblox added it is for the future when they add support.

local resolution = 4
local pos1 = Vector3.new(1232.5, -340.5, 517.5)
local pos2 = Vector3.new(-816.5, 302.5, -1531.5)
local region = Region3.new(pos1 , pos2):ExpandToGrid(resolution)

game.Workspace.Terrain:FillRegion(region , resolution , Enum.Material.Water)
0
Thanks, but that currently errors " Region has to be aligned to the grid (use Region3:ExpandToGrid)" which I just looked at on the wiki, but I have no idea how write it correctly. Thanks for what you have done already, I'm almost there. Your_Momdotcom 91 — 7y
0
i still need help Your_Momdotcom 91 — 7y
Ad

Answer this question