So I was reading this guide: http://howtomakeanrpg.com/a/classes-in-lua.html And it showed off a fancy way of turning a table into a class, but why not just use a script as a class and add all the methods and variables for Orc to that?
name = "Orc" maxHealth = 10; currentHealth = maxHealth; damage = 2; -------------------------------------------------------------------------------- function TakeDamage(amount) end function Attack(mob) mob.takeDamage(); end -------------------------------------------------------------------------------- function Start() end function Update() end -------------------------------------------------------------------------------- Start(); while(wait(1/60))do Update(); end
Classes are meant to be templates or "blueprints" for objects. You can "instantiate" a class to create a new object from that class, called an "instance".
The problem with using scripts like you do is you can't create multiple instances of them.
You could say you can copy them, but not create a new instance.
Though I suppose you could keep an original in ServerStorage or ReplicatedStorage and copy that.
Using scripts as classes isn't actually a bad idea, but copying, reparenting, or enabling/disabling scripts programmatically should be avoided.