local function I(I)if type(I)~="\115\116\114\105\110\103"then error("\065\114\103\117\109\101\110\116 \111\102 \067\114\101\097\116\101 \109\117\115\116 \098\101 \097 \115\116\114\105\110\103",2)end return function(R)R=R or{}local C=Instance.new(I)local y=nil local q=nil for I,R in pairs(R)do if type(I)=="\115\116\114\105\110\103"then if I=="\080\097\114\101\110\116"then y=R else C[I]=R end elseif type(I)=="\110\117\109\098\101\114"then if type(R)~="\117\115\101\114\100\097\116\097"then error("\066\097\100 \101\110\116\114\121 \105\110 \067\114\101\097\116\101 \098\111\100\121\058 \078\117\109\101\114\105\099 \107\101\121\115 \109\117\115\116 \098\101 \112\097\105\114\101\100 \119\105\116\104 \099\104\105\108\100\114\101\110\044 \103\111\116 \097\058 "..type(R),2)end R.Parent=C elseif type(I)=="\116\097\098\108\101"and I.__eventname then if type(R)~="\102\117\110\099\116\105\111\110"then error("\066\097\100 \101\110\116\114\121 \105\110 \067\114\101\097\116\101 \098\111\100\121\058 \075\101\121 \096\091\067\114\101\097\116\101\046\069\'"..(I.__eventname..("\'\093\096 \109\117\115\116 \104\097\118\101 \097 \102\117\110\099\116\105\111\110 \118\097\108\117\101\n\t\t\t\t\t       \103\111\116\058 "..tostring(R))),2)end C[I.__eventname]:Connect(R)elseif I==t.Create then if type(R)~="\102\117\110\099\116\105\111\110"then error("\066\097\100 \101\110\116\114\121 \105\110 \067\114\101\097\116\101 \098\111\100\121\058 \075\101\121 \096\091\067\114\101\097\116\101\093\096 \115\104\111\117\108\100 \098\101 \112\097\105\114\101\100 \119\105\116\104 \097 \099\111\110\115\116\114\117\099\116\111\114 \102\117\110\099\116\105\111\110\044 \n\t\t\t\t\t       \103\111\116\058 "..tostring(R),2)elseif q then error("\066\097\100 \101\110\116\114\121 \105\110 \067\114\101\097\116\101 \098\111\100\121\058 \079\110\108\121 \111\110\101 \099\111\110\115\116\114\117\099\116\111\114 \102\117\110\099\116\105\111\110 \105\115 \097\108\108\111\119\101\100",2)end q=R else error("\066\097\100 \101\110\116\114\121 \040"..(tostring(I)..(" \061\062 "..(tostring(R).."\041 \105\110 \067\114\101\097\116\101 \098\111\100\121"))),2)end end if q then q(C)end if y then C.Parent=y end return C end end

local function Create_PrivImpl(objectType)
	if type(objectType) ~= 'string' then
		error("Argument of Create must be a string", 2)
	end
	--return the proxy function that gives us the nice Create'string'{data} syntax
	--The first function call is a function call using Lua's single-string-argument syntax
	--The second function call is using Lua's single-table-argument syntax
	--Both can be chained together for the nice effect.
	return function(dat)
		--default to nothing, to handle the no argument given case
		dat = dat or {}

		--make the object to mutate
		local obj = Instance.new(objectType)
		local parent = nil

		--stored constructor function to be called after other initialization
		local ctor = nil

		for k, v in pairs(dat) do
			--add property
			if type(k) == 'string' then
				if k == 'Parent' then
					-- Parent should always be set last, setting the Parent of a new object
					-- immediately makes performance worse for all subsequent property updates.
					parent = v
				else
					obj[k] = v
				end


			--add child
			elseif type(k) == 'number' then
				if type(v) ~= 'userdata' then
					error("Bad entry in Create body: Numeric keys must be paired with children, got a: "..type(v), 2)
				end
				v.Parent = obj


			--event connect
			elseif type(k) == 'table' and k.__eventname then
				if type(v) ~= 'function' then
					error("Bad entry in Create body: Key `[Create.E\'"..k.__eventname.."\']` must have a function value\
					       got: "..tostring(v), 2)
				end
				obj[k.__eventname]:Connect(v)


			--define constructor function
			elseif k == t.Create then
				if type(v) ~= 'function' then
					error("Bad entry in Create body: Key `[Create]` should be paired with a constructor function, \
					       got: "..tostring(v), 2)
				elseif ctor then
					--ctor already exists, only one allowed
					error("Bad entry in Create body: Only one constructor function is allowed", 2)
				end
				ctor = v


			else
				error("Bad entry ("..tostring(k).." => "..tostring(v)..") in Create body", 2)
			end
		end

		--apply constructor function if it exists
		if ctor then
			ctor(obj)
		end
		
		if parent then
			obj.Parent = parent
		end

		--return the completed object
		return obj
	end
end
