Hello, if you are confused from the title. I’ll explain it more for ya.
Basically im trying to detect if a part is not detected by region3. however for some reason region3 will only detect parts that are in its sight. heres the code.
--Ignore list/Whitelist for the region3
local ViewportHandler = require(script.ViewportHandler)
local staticDelay = 60 -- the amount of time it takes to update static parts, in steps
local VF_Handler = ViewportHandler.new(script.Parent.ViewportFrame)
local renderDistance = 100
local list = {workspace.ViewportPart, workspace.CamPart, humanoidcurrent}
local PartLimit = 100
local RecordedParts = {}
local camera = Instance.new("Camera", script.Parent) -- Create the camera
camera.CFrame = script.Parent.Adornee.CFrame + script.Parent.Adornee.CFrame.LookVector*2
local viewport = script.Parent.ViewportFrame
viewport.CurrentCamera = camera
local function renderStatic()
--Create the region3 to detect the parts
local center = (camera.CFrame.LookVector*renderDistance)/2
local corner = Vector3.new(renderDistance/2,renderDistance/4,renderDistance/2)
local renderRegion = Region3.new(center - corner, center + corner)
--Get all parts within the region
local parts = workspace:FindPartsInRegion3WithIgnoreList(renderRegion, list, PartLimit)
--Loop through the parts
for i,v in pairs(parts) do
if v.ClassName == "Part" or v.ClassName == "MeshPart" or v.ClassName == "BasePart" or v.ClassName == "SpawnLocation" or v.ClassName == "CornerWedgePart" or v.ClassName == "WedgePart" or v.ClassName == "Decal" or v.ClassName == "SpecialMesh" then
if not v.Parent:FindFirstChild("Humanoid") then
if not v.Parent.Parent:FindFirstChild("Humanoid") then
if not v:FindFirstChild("Render1") then
render1 = Instance.new("BoolValue")
render1.Name = "Render1"
render1.Parent = v
partcurrent = VF_Handler:RenderObject(v,workspace.Commands.FPS.Value)
end
end
end
end
if #parts > 0 then
print(v.Name.." is in zone") -- is being printed
else
print(v.Name.." is not in zone") -- not being printed even though this should be
end
end
end
game:GetService("RunService").RenderStepped:Connect(function()
renderStatic()
end)