UPDATE 09/24/2020: This project is no longer maintained.
I’m not technically versed by any means. I only know how to write basic code in Lua.
I’ve had a recent fascination in replication especially with all the support topics lately. Along with that, I strongly feel like I’ve been providing misinformation or misinterpreting some threads. With these things in mind, I’m going to log some of my tests here.
Why post it on the DevForum? I check here every day so it’s easier to remember than crowding it on my trashy computer. On the off chance someone discovers this thread, well, free resources and information to read up on. Not like it’s too interesting.
Hope this gives me better insight to replication and so I can provide better, more accurate information.
4 Likes
New confirmations:
-
WaitForChild is not required to access static instances in ReplicatedStorage for LocalScripts running in PlayerScripts.
-
StarterPlayerScripts LocalScripts are protected by game.Loaded by nature of being a starter container (this should be implied given its name).
-
PlayerScripts does not implicitly exist under the LocalPlayer, even to a LocalScript running from there. WaitForChild is required to access it externally. Not yet sure if script.Parent
returns PlayerScripts despite this behaviour.
Testing materials:
- ModuleScript with default source in ReplicatedStorage
- LocalScript in StarterPlayerScripts
Source code:
Required ModuleScript:
local a = require(game:GetService("ReplicatedStorage").ModuleScript)
print(a) -- table: mem_address
PlayerScripts access:
local a = game:GetService("Players").LocalPlayer.PlayerScripts
print(a) -- Not reached, throws error
Several of my past projects as well as those I’ve taken part in or the helm over abuse WaitForChild for static instances in ReplicatedStorage, especially with regards to our library loader utility. As this module starts in ReplicatedStorage, it is static and WaitForChild is not required for it from LocalScripts.
I’m going to have a real blast refactoring, aren’t I…
3 Likes