Hello, I am trying to figure out how to get this FindPartsInRegion3 script to work, basically what it does is create a vector box in front of the character, and determine if there are any parts in front of the character:
print("Finding parts...")
local pnt1 = Vector3.new(selectedchar.Head.Position.X-1.5,selectedchar.Head.Position.Y-4,selectedchar.Head.Position.Z-2.5)
local pnt2 = Vector3.new((selectedchar.Head.Position.X-1.5)+3,(selectedchar.Head.Position.Y-4)+5,(selectedchar.Head.Position.Z-2.5)-4)
Region = Region3.new(pnt1,pnt2)
pfound = game.Workspace:FindPartsInRegion3(Region,nil,50)
print(Region.Size)
print(Region.CFrame)
print(#pfound)
if #pfound >= 1 then
print(#pfound .. " parts found")
end
for _,Part in pairs(pfound) do
--Do stuff with the parts
end
However, despite my best efforts the list is always empty, I even attempted to have it create a small part to mark where the center (the CFrame of the Region) is, and it seems to be in the correct spot every time, however the list is still empty.
Any ideas?
Thank you for reading. |