Square brackets are just another way of indexing an object using the dot operator.
object["member"] = example
-- is the same as
object.member = example
Therefore, you can indeed index properties by their name but given children are also accessed this way need to make sure Property_Name is a valid property of the instance.
For example:
local part = Instance.new("Part")
part["Size"] = Vector3.new(1, 1, 1)
If you aren’t sure, you can wrap the assignment in a pcall:
local function assign(object, index, value)
object[index] = value
end
local success = pcall(assign, yourInstance, yourProperty, yourValue)
local InstanceGot = Args[1]
local Function = Args[2]
local FunctionGot = InstanceGot[Function]
table.remove(Args,1)
table.remove(Args,2)
local success,err = pcall(FunctionGot(InstanceGot,unpack(Args)))
if not success then
warn(err)
end
return success and err or nil
And it just errors
Destroy
is not a valid member of Part “Workspace.Basepart”
InstanceGot is an Instance and Function is an string.