- What do you want to achieve?
I want to know if using ReplicatedFirst for client scripts is better than using PlayerScripts.
- What is the issue?
I don’t know if putting all player scripts and client-only instances into ReplicatedFirst will cause any issues. If it doesn’t, then I wouldn’t have to wait for things to load.
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried looking on the Developer Hub, but I couldn’t find anything that solved my issue.
1 Like
Use ReplicatedFirst for stuff that is important to be running while loading the game.
Use PlayerScripts for anything else used for general gameplay.
Otherwise, you’ll make yourself more susceptible to race conditions and needing to unnecessarily wait for things to be loaded in.
2 Likes
ReplicatedFirst
ensures that anything inside gets replicated before anything else, for example custom loading GUIs and such.
However you should put less important scripts in PlayerScripts
because they don’t need to be replicated immediately.
2 Likes
I use one local script that requires other modules; I don’t think there’ll be any race conditions. Even if ReplicatedFirst has a specific use, is it still okay to handle everything on the client in there? Also, what things would I be unnecessarily waiting to be loaded in?
It depends on your type of game. If you’re developing something that is entirely 2D UIs and doesn’t rely on other player interactions or whatever, you’re probably fine doing this. Most games are not like this, so the typical advice is to go with the standards.
If your code relies on things like a character, other player or world interactions, communicating with the server, then you’re probably better off just running your code normally in the proper order because otherwise your code will just be waiting for the world to be loaded in anyways.
ReplicatedFirst is optimized for running things that have no need for Workspace, ReplicatedStorage, etc. to be loaded in yet, there’s really no reason to stuff all your code in there for minimal perceived load time gains.
2 Likes
Thanks for your quick response.
I’m not looking for improvements in loading, I just don’t want to use WaitForChild
as much as I have to. I’d still be waiting for remote events to load in, but then I’d be able to easily index all my client modules and other client-only instances.
1 Like
If your script is in PlayerScripts, you’re guaranteed the entire tree of ReplicatedStorage to be there.
If you want to keep your code close together, you can also store a normal Script instance with RunContext set to Client and place it in ReplicatedStorage, it will run like normal and you can place your modules under/next to it.
2 Likes