So I have an NPC that just scans the area around itself for players. Here's the script ``` local region = Region3.new(Vector3.new(hrp.X - range, hrp.Y - range, hrp.Z - range), Vector3.new(hrp.X + range, hrp.Y + range, hrp.Z + range))
local parts = game.Workspace:FindPartsInRegion3(region)
for a, b in pairs(parts) do
print("----") print(b.Name) print(b.Parent.Name) print("----") if game.Players:FindFirstChild(b.Parent.Name) then print("Found player!") person = b.Parent end
end ``` (hrp is the NPC's HumanoidRootPart) (range = 15)
I get all the outputs but the output spits back everything that isn't part of my character. Here's what the output generally looks like ``` RightUpperArm
Dummy
LeftLowerLeg
Dummy
LeftFoot
Dummy
Handle
Rock *(Note: Rock is just a tool)
Handle
PaperHat
LeftUpperLeg
Dummy
``` Yeah it usually just detects itself and the house around it, even when I walk close. I can provide the entire script if it's neccesary, but I just included what I felt to be important.
This seems hard to debug from afar. Here are some changes I would suggest.
Visualize your region3 as you previously stated. Doing so is possible by creating a non-collide anchored transparent part with the same dimensions as your region and with the same center. Theoretically the code for that could look like ...
local region ... local visualizingpart = Instance.new("Part") visualizingpart.Anchored = true visualizingpart.CanCollide = false visualizingpart.Transparency = 0.5 visualizingpart.CFrame = region.CFrame visualizingpart.Size = region.Size
Other than that I don't see anything wrong with your code just eye-balling it. Check the hierarchy of the player character, perhaps body parts have a parent not named after the player?