Loop Help how i can get one part

how i can get only one part in evre time loop done

while wait(10) do
	for _,V  in ipairs(workspace.PartDi:GetChildren()) do
		if V:IsA("Part") then
			print(V)
		end
	end
end```
1 Like
local CurrentPart -- to store the Part we want

-- for loop:

if V:IsA("BasePart") then -- if Object is a BasePart
    CurrentPart = v -- Assigns Variable as Part
    break -- Exits the for loop
end

However, If you want it to be randomized

local PartInfo = {} -- to Store the Data for Parts
if V:IsA("BasePart") then -- if Object is a BasePart
    table.insert(PartInfo, V) -- Inserts Parts into table
end

CurrentPart = #PartInfo > 1 and PartInfo[math.random(1, #PartInfo)] or PartInfo[1]
-- Gets a Random Part from table

and if you really wanted to, you can simply remove all the Instances that arent BaseParts

3 Likes