Why am I getting an error?

Its because you are not using str but self instead. So just add before the str parameter another parameter and name it self. Then it should work:

Set = function(self, str)
	label.Text = str
	return label
end

If you want to understand self, check out this post!