Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is StarterGui an appropriate place to store LocalScripts?

Asked by
Seyfert 90
6 years ago

I use FE and want server to invoke the client in order for the client to interact with a GUI, I prefer to put the LocalScript in ReplicatedStorage for neatness but it seems the client never gets invoked unless I put the LocalScript in StarterGui. Is this "okay" practice?

1 answer

Log in to vote
1
Answered by
XAXA 1569 Moderation Voter
6 years ago
Edited 6 years ago

ReplicatedStorage does not run scripts. It's called -Storage for a reason.

There are really only five places where LocalScripts can run:

  1. A Player's Backpack, such as a child of a Tool
  2. A Player's Character model
  3. A Player's PlayerGui
  4. A Player's PlayerScripts
  5. The ReplicatedFirst service

It is obvious when you want to put a script in 1 and 5. But what about 2, 3, and 4? Here are some good rules of thumb:

For 2, put the LocalScript in the Character if a) You're manipulating the character itself and b) You expect the script to run again every time the player respawns.

For 3, put the LocalScript in PlayerGui if it manipulates the player's Gui.

For 4, put the LocalScript in PlayerScripts if you don't want it to reset whenever the player dies.

Because in your question, you're expecting the LocalScript to interact with the player's GUI, I would put it in the GUI.

tl;dr Yes, you can put it in StarterGui

0
Thank you Seyfert 90 — 6y
Ad

Answer this question