Hello!
I was wondering if there was a way to identify a part by its position.
Ex: let’s say a part is at coords (0, 0, 0)
Can I write a function to find that part based off its coordinates?
Hello!
I was wondering if there was a way to identify a part by its position.
Ex: let’s say a part is at coords (0, 0, 0)
Can I write a function to find that part based off its coordinates?
function findPartByPosition(pos)
for i,v in ipairs(workspace:GetDescendants()) do
if v:IsA("BasePart") then
if v.Position == pos then
return v
end
end
end
end
Thank u, I was about to do it by instancing a part to that position and use collisions system. That would of been really laggy. This is much better!
This still might slow down on games with LOTS of instances in the workspace
Oh I am doing it for a grid system I have for my floor or whatever. Basically it’s fine because it’s in a group. I just never thought of doing it this way so thank you
avoid looping, do this instead