Ok so I did'nt really know what to call the title, but I was having a function that could create a part and you pass trough some properties but instead having a varible in the funcation for every poropertie. I wanted to make a table with all properties in it. I tried this.

function AddProperty(PropertyTable,Obj)
	Obj[PropertyTable.Name] = PropertyTable.Value
end

function CreateObject(Type,Properties)
	local Obj = Instance.new(Type,game:GetService("Workspace"))
	
	for i = 1,#Properties do
		local PropertyTable = Properties[i]
		AddProperty(PropertyTable)
	end
end

CreateObject("Part",{{Name = "Size", Value = Vector3.new(10,10,10)}})

But when I type "Obj[PropertyTable.Name]" it tries to find a object inside the object with that name. Not changing the propertie. Is there any way to do this without using loadstring becuase I cant seem to be able to use it anymore.

2 comments

0

I imagine it's checking for an object in the object because that's how you've written it Obj[PropertyTable.Name] looks like Obj.PropertyTable.Name, which doesn't exist. I don't think you can do this without assigning a local variable so it becomes a single dot operation.

0

i got this answer from the discord server too but thanks