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
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
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.
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?
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.
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
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 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.