ModuleScript required by AssetId and reparented doesn't replicated correctly

Just realised the bug is different to what I first thought, so I’ve changed this post to match. ( I originally thought the “script” variable in ModuleScripts required by AssetId was incorrectly referencing a blank ModuleScript, however I now know the actual issue is as below )

Setting the parent of a ModuleScript required by AssetId to ReplicatedStorage doesn’t replicate the Source of the Module, causing anything to require it on the client to error.

Happens every time in my testing

You can reproduce this bug by:

  1. Creating a ModuleScript with the following code, named MainModule:
script.Name = "Hi"

script.Parent = game.ReplicatedStorage

return nil
  1. Upload that ModuleScript to Roblox and copy the AssetId
  2. Make a script in ServerScriptService and require the copied AssetId

Now start Play Solo and notice the ModuleScript has no Source on the client version

This happens with the latest version and I’m not sure when it started

2 Likes

This started happening a couple years ago. ModuleScripts and TextBox have hidden “Confidential” properties that prevent replication of relevant text fields. For ModuleScript, this was to prevent leaked references to the script from allowing it to replicate to a client. Perhaps some API in the future will allow the ModuleScript to unset its own Confidential property to allow this use case.

2 Likes

Oddly, it works correctly if I have the ModuleScript within another ModuleScript that just parents its child