Hello, basically I have some attributes that specify what I need for the region, and nothing is showing up when I run FindPartsInRegion3(region)? Can anyone help me?
local region = Region3.new(playerPlot:GetAttribute("TopLeftFront"),playerPlot:GetAttribute("BottomRightBack"))
local partsInRegion = game.Workspace:FindPartsInRegion3(region)
This method is deprecated. You should be using WorldRoot:GetPartBoundsInBox() instead.
Also, instead of wasting time with getting the corner positions and setting them with attributes, I recommend using this to calculate the corner positons:
local region = Region3.new(BasePart.Position - (BasePart.Size / 2), BasePart.Position + (BasePart.Size / 2))
Here is the documentation on GetPartBoundsInBox() if you need it.
If you still need help, feel free to ask me.
Would this work when there are a bunch of different plots, because there is a different region for every player. ( i mean the way instead of attributes)
GetPartBoundsInBox is the replacement method for FindPartsInRegion3. It will do the same thing. FindPartsInRegion3 will not work because it is deprecated.
Are you doing it correctly? It takes three parameters to work. The CFrame, size, and OverlapParams.
It should look something like this
local params = OverlapParams.new()
params.FilterDescendantsInstances = {--[[Add a model or other instance to this table. It will filter through all descendants inside of it.]]}
params.FilterType = Enum.RaycastFilterType.Include --// Enum.RaycastFilterType.Exclude if you don't want the descendants to be included
local parts = workspace:GetPartBoundsInBox(region.CFrame, region.Size, params)
Okay, but it is a pain to change all of the attributes if you move them for whatever reason. I would still recommend using the math I suggested in post #2 to make that part of your life easier. (If you haven’t already applied it.)
If you make a part that encompasses the whole area of where you want the player to place stuff, then have a script inside of the part, then you would create the Region3, use RunService.Heartbeat to constantly check the parts inside of the region using GetPartBoundsInBox(), and handle the events and functions necessary in that script.
It would look something similar to this:
local runService = game:GetService("RunService")
local part = script.Parent
local region = Region3.new(part.Position - (part.Size / 2), part.Position + (part.Size / 2))
local function Heartbeat()
local params = OverlapParams.new()
params.FilterDescendantsInstances = {--[[Remember to add the model/instance where you want to filter the descendants]]}
params.FilterType = Enum.RaycastFilterType.Include --// Change this to Enum.RaycastFilterType.Exclude depending on what you want it to do
local parts = workspace:GetPartBoundsInBox(region.CFrame, region.Size, params)
--// Make the rest of the code necessary for what you want in here
end
runService.Heartbeat:Connect(Heartbeat)