Attempt to get length of a Instance value

I need to get a random attachment
But i got this error adn i dont know how to fix and i looked for other posts but i found nothing
so the attachments are on drawers and i fisrt need to get all the attachments first so then i can get the positions

for _, Obj in pairs(script.Parent:GetDescendants()) do
	if Obj:IsA("Attachment") then
		local choosed = Obj[math.random(1, #Obj)]
		print(choosed)
	end
end

Give this a go.

local Attc = {}
for _, Obj in pairs(script.Parent:GetDescendants()) do
	if Obj:IsA("Attachment") then
        table.insert(Attc, Obj)
	end
end
local choosed = Attc[math.random(#Attc)]
1 Like

It worked thanks for your time

1 Like