I am currently experimenting with Region3 right now and the detection seems very weird for me.
local Point1 = game.Workspace.Point1 local Point2 = game.Workspace.Point2 local region3 = Region3.new(Point1.Position, Point2.Position) local Part = Instance.new("Part") Part.Anchored = true Part.CastShadow = false Part.CanCollide = false Part.TopSurface = Enum.SurfaceType.Smooth Part.BottomSurface = Enum.SurfaceType.Smooth Part.Transparency = 0.5 Part.Material = Enum.Material.Neon Part.BrickColor = BrickColor.new("Steel blue") Part.Size = region3.Size Part.CFrame = region3.CFrame Part.Parent = game.Workspace local ignoreList = {Point1, Point2, Part} while wait(1) do local region = workspace:FindPartsInRegion3WithIgnoreList(region3, ignoreList, 1000) --region variable must be inside the while loop because it has to be updated every second, if it is outside, it will only --run once and only get the first value it gets when the script starts. for index, value in pairs(region) do if value.Name == "HumanoidRootPart" then print("E") end end end
The script on top, works, as it detects a part named "HumanoidRootPart" and prints out something in response.
local Point1 = game.Workspace.Point1 local Point2 = game.Workspace.Point2 local region3 = Region3.new(Point1.Position, Point2.Position) local Part = Instance.new("Part") Part.Anchored = true Part.CastShadow = false Part.CanCollide = false Part.TopSurface = Enum.SurfaceType.Smooth Part.BottomSurface = Enum.SurfaceType.Smooth Part.Transparency = 0.5 Part.Material = Enum.Material.Neon Part.BrickColor = BrickColor.new("Steel blue") Part.Size = region3.Size Part.CFrame = region3.CFrame Part.Parent = game.Workspace local ignoreList = {Point1, Point2, Part} while wait(1) do local region = workspace:FindPartsInRegion3WithIgnoreList(region3, ignoreList, 1000) --region variable must be inside the while loop because it has to be updated every second, if it is outside, it will only --run once and only get the first value it gets when the script starts. for index, value in pairs(region) do local root = value:FindFirstChild("HumanoidRootPart") if root then print("E") end end end
However, for this script, it is meant to do the same thing, prints out something if it detects a part named HumanoidRootPart. But this doesn't seem to work. Can someone please tell me what I am doing wrong?
:FindPartsInRegion3WtihIgnoreList()
is literally finding all the given parts. It doesn't include models. For example, if you are scanning a region and printing to the output all the parts that enter it, and a player's character enters the region, it will begin printing all of the character's parts, NOT the model. Thus, in your line of code:
local root = value:FindFirstChild("HumanoidRootPart")
You're looking for the HumanoidRootPart
inside of the part found in the region. What's the problem? The HumanoidRootPart
is the part in the region. This means that in your code, you're essentially looking for a HumanoidRootPart
inside a HumanoidRootPart
, which is unlikely. You did it properly in your first script, not so much your second.