How to get all positions off all parts in a folder?]

Basically i want to get all positions off all parts in a folder

	local distance = Player:DistanceFromCharacter(workspace.Interactions:GetChildren().Position)
1 Like
local distances = {}
for i, v in pairs (workspace.Interactions:GetChildren()) do
if v:IsA("BasePart") then
table.insert(distances, Player:DistanceFromCharacter(v.Position)))
end
end

does this work?

1 Like

If you want to get all of the positions of a certain parent object you’ll need to use a for loop

For loops iterate through each item within a folder, model, etc.

for _, part in pairs(workspace.Interactions:GetChildren()) do
    local pos = part.Position
    local distance = Player:DistanceFromCharacter(pos)
    -- rest of the code that runs in this iteration
end

In case you are new to the idea of loops, here is a helpful article:

Hope this solves your issue! :slight_smile:
~ Xitral, Lua Programmer

2 Likes