Help with replacing a value in a table

Here’s my table:
image

For example, if “Hinge1” appears multiple times, how would I replace it each time it appears with “ReplacedHinge”? Thanks!

By the way, the way values are added to my table are:

	if myTable[rod] == nil then
		myTable[rod] = {}
	end
	table.insert(myTable[rod], aHinge)
	table.insert(myTable[rod], anotherHinge)

for i, v in myTable:GetChildren() do
if v == Hinge1 then
i = ReplaceHinge

is that correct?

Use:

for key, value in (table) do
    if value == someValue then
        table[key] = replacement
    end
end

:sunglasses:
image

1 Like
for rod, tbl in next, inputRodReturnSphereHinges, nil do
    local index = table.find(tbl, oldHinge)
    if index then
        tbl[index] = sphereHinge
    end
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.