Region3 tutorial (Easy Difficulty)

Yo this is a tutorial on what a region3 is and how u can use it.

Region3 is a data type that describes a volume in 3D space similar to an axis-aligned rectangular prism. simply put its like a part that only has a CFrame and Size Property. an example of a region3 is the terrain cells that terrain editor uses.

Region3 is commonly used as a replacement of hitbox parts.

it can be created using Region3.new() so its parameters are -

  1. the position of the top left front of a part
    2.the position of the top right back of a part

so the simplest way to calculate these Vector3 s and use them to make a Region3 is -

local part = Instance.new("Part")
part.Parent = game.Workspace

local TopLeftFrontOfPart = part.Position + Vector3.new(part.Size.X/2,part.Size.Y/2,part.Size.Z/2)
local TopRightBackOfPart = part.Position + (Vector3.new(part.Size.X/2,part.Size.Y/2,part.Size.Z/2)*-1)

local region = Region3.new(TopLeftFrontOfPart,TopRightBackOfPart)

now this region has 2 properties -

  1. region.CFrame which is the CFrame of the region3
  2. region.Size is a Vector3 of the Size of the part

so if u want to check what parts are touching a region3 there are 3 ways-

  1. local partsTouchingRegion = game.Workspace:FindPartsInRegion3() this returns a table with all the parts that are touching the region3, its parameters are the region,aPartToBeIgnored, maxParts (maximum no. of parts that can be returned)
  2. local partsTouchingRegion = game.Workspace:FindPartsInRegion3WithIgnoreList() this returns a table of all parts touching the region3 except the ones in the ignore list. its params are the region, a tableWiththePartsToIgnore , maxParts
    3.local partsTouchingRegion = game.Workspace:FindPartsInRegion3WithWhiteList() this returns a table of parts that are in the region3 and in the whitelist. its params are the region, tableWithPartsToNotIgnore, maxParts

you can use different methods based on your requirements but for this tutorial I am going to be using the 1st one since its the simplest

local part = Instance.new("Part") --creates part
part.Parent = game.Workspace     --setsParent
part.Name = "Chidori go brrrrrr" -- sets name of parent u *dont* need to do this I did it for fun
part.Size = Vector3.new(15,15,15) 

local TopLeftFrontOfPart = part.Position + Vector3.new(part.Size.X/2,part.Size.Y/2,part.Size.Z/2) --calculates 1st parameter for region3
local TopRightBackOfPart = part.Position +(Vector3.new(part.Size.X/2,part.Size.Y/2,part.Size.Z/2)*-1) -- calculates 2nd parameter for region3

part.Size = Vector3.new(5,5,5)
local region = Region3.new(TopLeftFrontOfPart,TopRightBackOfPart) --creates region3

local getTouchingParts = game.Workspace:FindPartsInRegion3() -- gets table of all parts in region3

for i,v in pairs(getTouchingParts) do --loops through the table
		print(v.Name) -- prints name of the part in the loop right now
end -- ends the loop why am I even writing so many obvious things...

so the above code creates a part then creates a region 3 with the the same position and size as the part (and later makes the part smaller just like that) after this it gets a table of all the parts in the region 3 and then loops through it to print the name of all parts in the region3

hmu on discord (Ichigo#5972) for requesting more tutorials

49 Likes

if you have any questions feel free to drop em here or dm me if u arent a member yet

2 Likes

This doesn’t explain well to Region3 newbies. What I can explain is that it takes 2 arguments, the first argument is the positional value of the starting point of the prism and the last argument is the ending point of the prison. Basically what it means is that it will create a prism based on these 2 opposite side points.

You can just supply the parent of the Instance in the second argument of Instance.new().

For anyone wants to see other stuffs of Region3, take a look at here.

1 Like

I appreciate ur feedback but the starting point and ending point of prism thing is more confusing since it doesnt give usage based context wht I am trying to say is that this is teaching them usage based its a tutorial not a how it works episode

4 Likes

i have been getting confusion with this

i would like to know how the Region3 size works as it is like this:
Region3.new(vector3.new(0,0,-3), vector3.new(2,5,3))
i cant properly understand what the first, second and third digit vector do

3 Likes

the first vector3 is for top-front-left of the region3 and the 2nd vector3 is for the bottom-back-right of the region3.

1 Like

i mean what does the digit in it (0,0,-3) do its its position ?

1 Like
(0 --[[X co-ordinate of top-front-left of region]],0--[[Y co-ordinate of top-front-left of region]],-3--[[Z co-ordinate of top-front-left of region]])
2 Likes

Is there any way you can illustrate this so I can understand it more. You could also add some illustrations throughout so it makes it easier to understand in general. For example, show what happens to the part when one or even two of the parameters of region3 are altered. Thank you.

2 Likes

I think he chose it to not parent it since parenting it within an intance slows down the performance.

I might be wrong here but I believe that’s the reason why.

3 Likes

for some reason, whatever number I put in-game.Workspace:FindPartsInRegion3() in the third parameter it always stops at some point no matter what. It doesn’t matter if I put in a huge number it stops working no matter what, is it possible to fix this?

2 Likes

here is the script:

local player = game.Players.LocalPlayer
local RemoteEvent = game.ReplicatedStorage.RemoteEvent

RemoteEvent.OnServerEvent:Connect(function(player)
local c = player.Character
local region = Region3.new(Vector3.new(1,1,1), Vector3.new(10,10,10))
local Rt = workspace:FindPartsInRegion3(region, nil, 20)
local part = Instance.new(“Part”, game.Workspace)
part.Transparency = 0.1
part.Anchored = true
part.Size = region.Size
part.CanCollide = false
part.CFrame = c.HumanoidRootPart.CFrame + c.HumanoidRootPart.CFrame.LookVector * 7
for i, part in pairs(Rt) do
if part.Parent:FindFirstChild(“Humanoid”) ~= nil then
part.Parent.Humanoid:TakeDamage(10)
end
end
wait(.1)
part:Destroy()
end)

2 Likes

the region check only works in tht one frame tht u check it in it doesnt have a duration

1 Like

I wouldn’t recommend this at all, it greatly effects performance and is slower.

3 Likes

I have a questions.Is it possible to create terrain from Region3 ??.I know this questions is out of topic bit I just want to know

1 Like

Have you read the rules? It states that you should explain instructions well.

Provide instructions ; step-by-step instructions should be clear and well-explained.

1 Like

Doesn’t make any sense, I’m using option .

1 Like

i did provide instructions but i said no for explaining how the region3 works behind the scenes since i wanted it to be ez for new ppl, i am showing them how to use it here not how it works

You are just tell them what it does, which can they can easily find out from the developer hub. This tutorial has literally no use at all. :I

It makes alot of sense, the article thoroughly explains why its a bad idea. Roblox staff themselves are advising that you don’t use the patent argument.

1 Like