Hello, I am trying to make a script which finds a number of how many models are touching a part. The model is NPC and it has same name as other NPCS there is ussualy alot of them. Here is a script that dosen't really work it gives me only an amount of parts touching but not how many models touching.
local part = script.Parent
local TopLeftFrontOfPart = part.Position - (0.5 * part.Size)
local TopRightBackOfPart = part.Position + (0.5 * part.Size)
local region = Region3.new(TopLeftFrontOfPart,TopRightBackOfPart)
local count = 0
script.Parent.Touched:Connect(function()
for _,Part in pairs(game.Workspace:FindPartsInRegion3(region,nil,math.huge)) do
if Part.Parent.Name == "Dummy" then
count = count + 1
end
end
print(count)
count = 0
end)
Thanks.

1 comment
It wouldn't work because it would still do it with every part of model