Help with Region3

Hello,

I am currently trying to use the Terrain:ReplaceMaterial() function, however when working with Region3's It starts getting complicated. I find the documentation on the Developer Hub very vague when it comes to Region3's and scripting terrain in general. Region3 (roblox.com).

They are saying that this is the code to make a Region3 1. local region = Region3.new(Vector3.new(2, 3, 4), Vector3.new(8, 6, 5)) However I don’t understand why there are two Vector3’s and no CFrame. Then it goes onto saying that if you print region it should output 1. 5, 4.5, 4.5, 1, 0, 0, 0, 1, 0, 0, 0, 1; 6, 3, 1 They say that the first two numbers are the CFrame however where are those numbers coming from?

Anyway to move on this is my code I’m having problems with. I don’t know where to put my CFrame values and where to put my Vector3 values.

First I tried this:

local region = Region3.new()
region.CFrame = CFrame.new(25,0,-1269)
region.Vector3 = Vector3.new(3397,512,1337)

However got the error: CFrame cannot be assigned to

So then I tried this:

local region = Region3.new(Vector3.new(25,0,-1269), Vector3.new(3397,512,1337))
--The upper line means:
--local region = Region3.new(Vector3.new(CFrame), Vector3.new(Vector3))

Then I got the error: (Something allong the lines of) Region3 is too large

Although you might think my error is that the Region 3 is too large I’m able to do the same size zone using the editor.

I hope I can get some help.
Thanks

I really am not the kind of person who knows this much stuff, but this a block that creates water.
It creates water by doing this:

--XxCookieFlxlfxX
game.Workspace.Terrain:FillBlock(script.Parent.CFrame, script.Parent.Size, Enum.Material.Water)
wait(1)
script.Parent:remove()

Inside studio editer:
atudi
Studio Playmode:
utudi

This would work however because I have a script that changes the height of the water I need to clear the water before I recreate the water either bigger or smaller every time the water height changes.

Region3s are built with 2 points. Think of it as a 3d prism, and there are 2 corners directly opposite of each other which you can move around to change the size of the Region3.

You could use some complex math functions, or you could use a module that does it for you. RotatedRegion3 allows you to construct a Region3 with a CFrame and a Size because this module allows rotated region3s. Roblox Region3s are square, and therefore cannot be rotated, meaning that it only needs two points to create the region.

1 Like