Inside a model there are more models and every one of them has a part called "Main". Every part must be close enough to at least one other part.
for _, model in ipairs(mainModel:GetChildren()) do
closeEnough = false
checkFor = model:WaitForChild("Main")
for _, model2 in ipairs(mainModel:GetChildren()) do
checkWith = model2:WaitForChild("Main")
if <checkFor is closer to checkWith than 4 studs> then
closeEnough = true
end
end
if not closeEnough then
script:Destroy()
end
end
Obviously, I also check if checkFor~=checkWith, but I didn't include that here.
What I want to know is, how to check the distance between two parts, and if there is a more efficient way to do what I'm trying to accoplish.
