The command bar result is different with the script/localscript

I was researching roblox’s official Weapons Kit, and while I was here at ShoulderCamera, I was going to modify some features, I use the command bar trying to
image image

print(require(game.ReplicatedStorage.WeaponsSystem.WeaponsSystem).camera)

the print result is nil,but when I tried to use the same code in the local script, instead of printing nil, I printed the correct return value.

Because the official Weapons Kit all codes will only exist in a copy in ReplicatedStorage, much of the Modulescript is a mix of server-side and client-side code, the follow code

require(game.ReplicatedStorage.WeaponsSystem.WeaponsSystem).camera

is attempting to access the client-side ShoulderCamera.

I saw a post saying that the Command bar does not update automatically. Is this a studio bug?

1 Like

No it is not a studio bug, the solution is that it is intentional. Use require(script:Clone()) Roblox does this to avoid overflowing memory.

I think this can be misleading for new developers. Roblox needs an internal cache to handle require requests from the command line. If a module script has script.AnyThing in it, the entire module script cannot be debugged on the command line, you said require(script:Clone()) will report a loading error, you can only set breakpoints or print results.
I think the Command bar is a very quick way and Roblox officials should unify the results of these three debugging methods

The following is the result of my actual test. Module script will report an error when accessing other instances. The only way to avoid this error is to change all the script keywords of the Module script, which is really frustrating. :smiling_face_with_tear:

I have changed all the script keys and replaced them with the global game.ReplicatedStorage, it is still nil, but it is not nil in localscript, I cannot understand, I can only think it is a bug of studio, can roblox staff help me? :sob:
CmdTest

It is not a bug! Roblox needs to save memory so when you require it, It goes under a single Hexadecimal Memory Address, when you clone it the module replaces another Hexadecimal Memory Address with the new contents.

The fact that you said that makes me think that you only believe “roblox staff” are correct.

Because we don’t know how they implement it internally, if Roblox can open source that part of the implementation code, I think our community can solve this problem

You kindof can, Luau is opensource.

What you said about saving memory is correct, but the Module Script needs to be automatically updated after the developer changes it. Currently, it only updates after the game runs, which I think is their internal negligence. If I want to update module Script without running the game, Each time I had to delete the entire Module script and copy it back in order to automatically update it

I know Luau is open source, but such a large library is not something I can master in a short time, so I hope the Roblox staff can give me an answer

Server and Clients get their own copy of any module script they require. This isn’t a bug.

I know this, so I’m showing localScript running, and the command line is also running in a local environment, and the entire Module script runs only in the local environment(Shoulder Camera has no effect on servers, only local player controls), with no changes made to server replication

My guess is that the local environment of the command line is different from the local replicatedStorage of the localscript, and localscript makes changes to the local ReplicatedStorage, which does not affect the server replicatedStorage. So the Roblox server decided that I hadn’t made any changes to the replicatedStorage, including the local replicatedStorage, so the command line also didn’t update the local changes.OMG, that logic is so complicated.