local allBoats = {workspace.BoatsAndMore:GetChildren()}
local min = 70
local target = nil
local theBoatThatsShooting = script.Parent
for i,boat in next, allBoats do
if theBoatThatsShooting ~= boat then
local distance = (theBoatThatsShooting.Position-boat.Position).Magnitude
if distance < min then
min = distance
target = boat
target:Destroy()
end
end
end

Whats the problem?
attempt to perform arithmetic (sub) on Vector3 and nil
No idea what that means in any way.
This script is supposed to destroy the nearest boat.

Thereâ€™s nothing wrong with if checking the boat is nil or not.
For right now, im getting the error
Position is not a valid member of Model â€śWorkspace.BoatsAndMore.inhabitnpcâ€ť
on line 7.

local allBoats = workspace.BoatsAndMore:GetChildren()
local min = 70
local target = nil
local theBoatThatsShooting = script.Parent
for i,boat in next, allBoats do
if theBoatThatsShooting ~= boat then
local distance = (theBoatThatsShooting.Position - boat.Position).magnitude
if distance < min then
min = distance
target = boat
target:Destroy()
end
end
end

local allBoats = workspace.BoatsAndMore:GetChildren()
local min = 70
local target = nil
local theBoatThatsShooting = script.Parent
for i,boat in next, allBoats do
if theBoatThatsShooting ~= boat then
print(theBoatThatsShooting:GetFullName(),boat:GetFullName())
local distance = (theBoatThatsShooting.Position - boat.Boat.Position).magnitude
if distance < min then
min = distance
target = boat
target:Destroy()
end
end
end