You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I Want To Find The Closest Part To Main Part To Pathfind To
What is the issue? Include screenshots / videos if possible!
I Dont Know How To Do It And I Cant Find Anything
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Ive Tried Looking Around But I Cant Find What I Need
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local Char = script.Parent
repeat
wait(0.5)
local AllParts = workspace.Food:GetChildren()
for i, IndividualPart in pairs(AllParts) do
local Distance = (Char.Position - IndividualPart.Position).magnitude
print(Distance, IndividualPart)
end
until false
local greatestDistance
local farthestPart
for i, IndividualPart in pairs(AllParts) do
local Distance = (Char.Position - IndividualPart.Position).magnitude
if Distance > greatestDistance then
greatestDistance = Distance
farthestPart = IndividualPart
end
end
farthestPart blah blah code