I am trying to do a region around an npc that detect any model in the region
I write a code and created a Region3 in it, but the return of FindPartsInRegion3 always an empty table even if the region was so big.
this is the code but it prints nothing :
local npc=script.Parent
local Point1 = npc.HumanoidRootPart.Position + Vector3.new(1000,0,1000)
local Point2 = npc.HumanoidRootPart.Position + Vector3.new(-1000,0,-1000)
local RegionAroundNpc = Region3.new(Point1,Point2)
while wait() do
local ModelsInRegion = game.Workspace:FindPartsInRegion3(RegionAroundNpc ,nil,100) --get models in specefic region
for _,Model in pairs(ModelsInRegion) do
print(Model.Name)
wait()
end
end
Can anyone help fixing the code ?