Can you create your own classes in lua?

I know this is probably a really dumb question, but I know in other languages, (like java) you can create your own classes. Can you also do this in lua?

You sure can! Here’s a great tutorial by magnalite: All about Object Oriented Programming

1 Like

Check out this post: All about Object Oriented Programming

How I personally organise my classes…
gernlib is a personal library of functions
gernstance is a class I wrote that all my classes inherit from (where self = {} inside .new())

--[[ CLASS via AeroFramework




local class = {}
local SELF = class
class.__index = class

local gernlib = require(game.Workspace:WaitForChild('GernLib'):WaitForChild('module'));


    local self =
    self.sub_class = self.class
    self.class = "class"
    setmetatable(class, gernlib.classes.gernstance)
    setmetatable(self, class)

    return self


return class

I just use the typical OOP Object for Lua

local Object = {}
Object.__index = Object

  local self = setmetatable({
    param1 = param1;
    text = "Heyo";
  }, Object)
  --you can use this area here to initialize other things you want to use but can't set in the table, or call functions on it.
  return self

return Object