How would I convert Roblox datatypes to strings that would work when assigning a value to a property in a script?

I want to create a script to convert DataTypes (Color3, UDim2, Vector3, etc) to strings (Color3.new(), UDim2.new(), Vector3.new()) that could be used for assignment in scripts, yes I’m trying to make an object to Lua plugin.

Is there any library or method I could do this? At first I tried to see if the datatype was a primitive, if so then just return it, if not then ("%s.new(%s)"):format(datatype, value). The problem with both of these? strings. “value” in that script would be the parameters converted into a string, for example Whatever.new(“string”, 2) would become “string, 2”. As you can see strings used quotes and I couldn’t figure out how to make it check if it was a string, add quotes, etc. And don’t even get me started with handling Enums in addition to that… so I ask again is there any library or method I could do this with?

Thanks so much in advance.

1 Like