Hi , I am trying to make a game . I organise the game by using a modular approach where there is only one server and one local scripts . Those 2 scripts load all the modules and the modules are the one that run code . I am wondering how do i use actors in this case?
you can’t run code in parallel only using modulescripts, so what i’ve done in the past is create a “base script” that contains everything to be run in that vm and then clone that script to a new actor whenever needed, interacting with it via BindToMessage/SendMessage
getting data back from a different vm is a massive pain though, i tend to avoid it but it can be done via a BindableFunction
or two BindableEvent
s
Only using two scripts isn’t a good way to organize or create a game in general. It’s easier, better, maybe even better performing to use multiple scripts.
hmm, is there any script organisation videos you recomand?? I used modular approach because i needed the scripts to share info easily. However, i currently need to use actors to reduce lag
A “Modular approach” doesn’t mean only two scripts entirely. Modules help you to organize, sure, but you shouldn’t limit your code to modules.
For sharing info, there are many ways to do that. You can use BindableEvents or BindableFunctions to connect with scripts on the same side of Run Context (Local scripts or Server scripts) or you can use RemoteEvents or RemoteFunctions to connect with the other side. (Local-Server, Server-Local)
All games are different. You should look up tutorials on YouTube or on the devforum to find what you want.