Classes in Luau for no reason at all

Classes as a module. Saving ten lines of code while sacrificing your sanity and well-being. This module is extremely poorly made. Before you ask, there is no reason why you should use this over x, as whatever it is, and however poorly it is made, x is still going to always be better than this.

RBXM:
Class.rbxm (1.1 KB)

Usage:

local Class = require(game.ReplicatedStorage.Class)

local Dog = Class "Dog" {
	New = function(self, name, breed) -- The function "New" is required
		self.name = name
		self.breed = breed
		self.happiness = 100
	end;
	
	Pet = function(self)
		print("That satisfies me")		
		self.happiness += 5
	end;
	
	GetName = function(self)
		print("My name is", self.name, "and I am an", self.breed)
	end;
}

local Fluffy = Dog.new("Fluffy", "American Eskimo")
Fluffy:Pet()
Fluffy:GetName()

The only reason you should even load that .RBXM into your game is to learn how most people make classes. Please don’t actually use this, one glance into the code and you’ll see how bad it is.

Can’t load the RBXM?

1 Like

Or upload it to a Gist so people (especially mobile forum users) can view it.

Good idea, I’ve done that. I’ll probably add comments to the gist so more people can understand it later on