How do I remove parts from a dictionary?


local ogpart = Instance.new("Part")

local part = ogpart:Clone()

local dict = {
    parts = {}
}

dict.parts[part] = {
     OGPart = ogpart
}

how would i remove this part from the dictionary? dict.parts = {} works but its not what im looking for as I would want to put multiple parts in this dictionary.

dict.parts[part] = nil and table.remove(dict.parts, table.find(dict.parts, part)) also doesnt work

dict.parts[part] = nil is how you remove dict.parts[part].
dict.parts[part].OGPart = nil will remove OGPart.
If neither of those are what you want, you might need to provide more details. This structure is a little messy.

1 Like

sorry for the messy structure yeah. I swear I tried that and when I loop through the table, the part still appears in it. I’ll try to redo this and see if I can get it to work

Sounds good. Let me know if that doesn’t work. Also if ogpart is the only entry in that second dictionary, you should probably remove the second dictionary.
dict.parts[part] = ogpart

This didn’t work to you because table.find works for arrays, not for dictionaries. For dictionaries you might need to do one of these:
1.dict[parts]
2.dict.parts

That simply worked but made your inner table nil, hence anything in that inner table, would be nil aswell.

The solution will be what @JarodOfOrbiter already wrote above:

2 Likes

I had to redo how my dictionary was set up, that method now works thank you