I’m curious, how do I use dictionaries as parameters for modulescript functions? Like for example, change a property of a part via data in a dictionary or something like that?
An example of what I’m thinking of:
--[[MODULESCRIPT]]--
function module.CreatePart(parameterTest1)
local partNew = Instance.new("Part")
-- INSERT HOW IM SUPPOSED TO USE DICTIONARIES TO CHANGE PART PROPERTY
end
--[[SCRIPT]]--
local dictionaryProperty = {
["Anchored"] = true,
["CanCollide"] = false,
["Name"] = "testPart"
}
module.CreatePart(dictionaryProperty)
You can just go through the dictionary in a pairs loop and use the key in each iteration to determine where to put the property.
function module.CreatePart(parameterTest1)
local partNew = Instance.new("Part")
for PropertyName, Value in pairs(parameterTest1) do
partNew[PropertyName] = Value
end
end
--[[SCRIPT]]--
local dictionaryProperty = {
["Anchored"] = true,
["CanCollide"] = false,
["Name"] = "testPart"
}
module.CreatePart(dictionaryProperty)