Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local properties = {
- "Size", "Position", "Parent"
- }
- local values = {
- v3 = "Vector3.new",
- cf = "CFrame.new"
- }
- local getProperty = function(property)
- for _, value in ipairs(properties) do
- if value:lower():sub(1, #property) == property:lower() then
- return value
- end
- end
- return false
- end
- local getValue = function(value)
- for match, replace in pairs(values) do
- value = value:gsub(match, replace)
- end
- return loadstring("return " .. value)()
- end
- local define = function(class, parent)
- return setmetatable({
- class = class,
- parent = parent,
- props = {},
- create = function(self)
- local instance = Instance.new(self.class, self.parent)
- for index, value in ipairs(self.props) do
- instance[value[1]] = value[2]
- end
- return instance
- end
- }, {
- __newindex = function(self, key, value)
- table.insert(self.props, {getProperty(key), getValue(value)})
- end
- })
- end
- return define
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement