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.