Bulk setter for Attributes

I would like a method that allows a developer to set multiple Attributes with a single call.

The current developer solution looks like this:

local function SetAttributes(instance, attributes)
	assert(typeof(instance) == "Instance")
	assert(typeof(attributes) == "table")
	
	for key, value in pairs(attributes) do
		instance:SetAttribute(key, value)
	end
end

Presumably, creating a loop of assertions and Set calls is leaving a lot of performance on the table.

Adding Instance:SetAttributes(dict) would be very handy in situations where a plethora of Attributes are applied to an Instance at the end of a process that might run each heartbeat or physics step, such as a car’s engine data.

25 Likes