I dont understand really much what is actor and what is the porpose of it, ive read the documentation but i still dont understand what can i do with actors and why should i use them.
The documentation said i can synchronize and desynchronize and use them as containers.
Can the actors be used as a class like the Actor class in unreal engine? meaning i can use it to create objects and npcs?
They can be thought of as seperate bins that allow simaltanous code execution. Normally lua is single threaded/serial, which means that all code is ran in sequence, which can cause problem if large computation jobs need to be done, causing your game to lag or freeze.
Actors in combination with some specialized code, allows code to ‘desynchronize’ from the main sequence loop, allowing them to run at the same time as the rest of the game, but not cause freeze ups.
Pretty much what @AC_Starmarine said; they allow code to be run in parallel.
This is another way of saying you can run truly asynchronous code. Instead of using only one thread, you can use a second thread to run tasks simultaneously. It’s good for memory-heavy tasks, like handling NPC movement as you said before. Messages can be sent to actors and received by code on the actor with Actor:SendMessage and Actor:BindToMessage/Actor:BindToMessageParallel. You can connect code in parallel with RBXScriptSignal:ConnectParallel, and cause blocks of code to run in parallel with task.desynchronize().
It’s important to note that code won’t run asynchronously by default when in an actor; you need to use one of the methods to set it.
Also, you also need to be aware of thread safety. Some functions, of Instances for example, aren’t safe to be called in parallel and must be called in serial. You can run code in serial again after it’s been desynchronized with task.synchronize.