It basically loops through the table, then checks if the index (e.g. ‘Anchored’) is found as a property in the part. If it is, set the value (e.g. true) of the index to the part’s property.
Original author of the quoted reply here. While this functions does the job as intended, I would recommend adding additional code to make sure Parent property is assigned at the very end to make sure it’s not slowed down by extra internal event work when changing properties inside the for loop:
function module.CreatePart(parameterTest1)
local partNew = Instance.new("Part")
local parent = parameterTest1.Parent
parameterTest1.Parent = nil
for PropertyName, Value in pairs(parameterTest1) do
partNew[PropertyName] = Value
end
partNew.Parent = parent
parameterTest1.Parent = parent
end
--[[SCRIPT]]--
local dictionaryProperty = {
["Anchored"] = true,
["CanCollide"] = false,
["Name"] = "testPart"
}
module.CreatePart(dictionaryProperty)