Everyone would be throwing rocks at me for not using metatables lol
local car = {}
function car.newCar(brand, year, model)
local self = {}
self.Brand = brand
self.year = year
self.model = model
return self
end
local FiatUnoMille = car.NewCar("Fiat", 2005, "Fiat Uno Mille")
print(FiatUnoMille.brand)
print(FiatUnoMille.year)
print(FiatUnoMille.model)
return car
OOP is scary
It looks good although I never used it myself, but is it really worth the extra effort because modules just seem way more convenient.
But if you tried, I guess I could try OOP aswell.
That code looks nice, although metatables would improve its error handling and efficiency a lot. If you or anyone else doesn’t know how to use metatables but would like to, I think B Ricey does a good job on his YouTube channel explaining them in the “OOP in Roblox” Scripting tutorials.
metatables are not needed, but if you want to integrate some custom functions, you’d need to make it dot notation and pass the “FiatUnoMille” yourself as opposed to just calling a method on FiatUnoMille
I will be happy to give feedback if you want to add more to it. At the moment there is no problem with it.
Some things to consider, what is you want to create lorries, motor bike, quads etc… then maybe this should be vehicle and each vehicle would have it’s own type.