Hi, I'm a bit rusty at scripting at the moment and I'm trying to make a closest part script.The problem is that it selects all the parts and not the closest one. Here's the script:
while wait() do for i,v in pairs(workspace:GetChildren()) do if v ~= script.Parent and v ~= workspace.Baseplate and v.ClassName == script.Parent.ClassName then local mag = (script.Parent.Position - v.Position).magnitude if mag <= 50 then print(v.Name) end end end end
Any help is appreciated