Trying to understand how ModuleScripts work within Actors

Been having the following problem:
When having both a ModuleScript and multiple Scripts inside an Actor, the Scripts changes to the ModuleScript are replicated to every other script (itself, other simple scripts inside actor, and the ModuleScript itself).
But, when the ModuleScript alters itself, the change is not replicated to anyone else but itself.

So, script changed to the module are replicated, but the module itself isn’t?

What am i missing? is this working correctly? this is very, very weird behavior.

Am i wrong in understanding from this behavior that the ModuleScript, even when it’s inside an Actor, is not actually working within the Actor?

1 Like

Issue: Changes to a Script converted from a ModuleScript replicate, but ModuleScript changes do not.

Explanation:

  • ModuleScripts are for shared code and don’t auto-update Scripts.
  • Scripts only reflect changes locally unless explicitly updated.

Solution: Make all shared code changes in the ModuleScript and ensure Scripts require it correctly.

… yeah, just took a look at your post history, please don’t use AI to answer others in a Dev Forum.


I’m not sure you understood my problem.

I’ve been using this system for years at this point, just now got to try the Actor system for better Multi-threading and this is a new problem exclusive to how Actors interact with ModuleScripts, not using ModuleScripts themselves.

Changes to a Script

The changes are to a ModuleScript.

converted from a ModuleScript.

i’m not sure what you mean by “converted from a ModuleScript”, it’s just a ModuleScript with Tables for sharing data (without using the SharedTables system) and some Functions.

replicate, but ModuleScript changes do not.

yeah, no, the change to the ModuleScript made by Scripts do replicate, but the changes made to the ModuleScript by itself (meaning, the functions inside it) does not replicate to other scripts.

Example:

  • Module_0 has table { A=1, B=2, C=3, },
  • Script_1 changes B to 3.
    at this point, any script or module will see that B==3.
  • Script_2 changes A to 4,
    any script or module will see that A==4 and B==3.
  • Module_0 changes C to 1.
    only Module_0 sees the change, every other script sees C==3.

Explanation:

  • ModuleScripts are for shared code and don’t auto-update Scripts.
  • Scripts only reflect changes locally unless explicitly updated.

Solution: Make all shared code changes in the ModuleScript and ensure Scripts require it correctly.

This is the basics of a using ModuleScript, and not at all what i wrote about having a problem with.


To me, this seem to imply that the Module is being cache’d by the VM, so the Scripts (all inside the same Actor) change the Module (also inside the same Actor) but the change is only recorded locally, and that applies to the ModuleScript which also sees the changes, but when the Module changes itself, it somehow does not?