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

A guide on where to post various scripts into certain Studio services?

Asked by 5 years ago
Edited 5 years ago

Roblox has become increasingly complicated it seems on inserting scripts into a game. Expecially for people who are new to scripting or have no knowledge of it at all. Is there any methods that you can use to determine where a script goes? Such as the StarterPack, ReplicatedFirst, ReplicatedStorage, ServerScriptService, ServerStorage, StarterGui, StarterCharacterScripts, StarterPlayerScripts & Workspace. Anymore just placing them into Workspace usually doesn't work anymore. Please let everyone in on some hints on how to figure this stuff out. Besides relying on scripts that tell you where to place them. I suppose in some scripts there is code that let's you get some insight on where it might go. As for that understanding I have not though. (Tags: Script, LocalScript, Modules, Service, Instance, Placement, Guide, Tutorial, Roblox, Studio. )

Easy comparable image can be found here: https://i.redd.it/2f5hicrulsp31.png

(Scripts & Services: Where To Place Them In. )

Roblox has become increasingly complicated it seems on inserting scripts into a game. Expecially for people who are new to scripting or have no knowledge of it at all. Is there any methods that you can use to determine where a script goes? Such as the StarterPack, ReplicatedFirst, ReplicatedStorage, ServerScriptService, ServerStorage, StarterGui, StarterCharacterScripts, StarterPlayerScripts & Workspace. Anymore just placing them into Workspace usually doesn't work anymore. Please let everyone in on some hints on how to figure this stuff out. Besides relying on scripts that tell you where to place them. I suppose in some scripts there is code that let's you get some insight on where it might go. As for that understanding I have not though. (Tags: Script, LocalScript, Modules, Service, Instance, Placement, Guide, Tutorial, Roblox, Studio. )

(Scripts & Services: Where To Place Them In. )

ReplicatedFirst: Client-side scripts will run here. LocalScripts may need to wait for objects. Local Scripts can go here and run. Game. Loaded event only place! Can make GUI Loading Screens and tutorials. The earliest possible point. Objects should be parented to it. ReplicatedStorage for Objects that don't need loading first.

ServerStorage: All items for the Server to access exlusively. NOT replicated to the Client. Used for inactive item models, entire maps, etc. Scripts of any kind do not run here except Modules. Use ReplicatedStorage instead for both client and server usage.

ReplicatedStorage: Both the Server and Client can access. RemoteEvents generally go here. Contents are replicated to all connected clients. Allows objects to be stored until needed. Great for RemoteFunctions & RemoteEvents. Scripts and LocalScripts will not run in here. Module scripts can accessed and run from here. Objects can be accessed from a Script or LocalScript. Clients can access and modify ReplicatedStorage. Client changes do not replicate for server or other clients. Objects that only server requires access to, use ServerStorage.

ServerReplicator: Replicate changes from clients and the server over to a certain client.

ServerScriptsService: Scripts placed here run only on the server. Allows for secure storage of your scripts. Placed in areas where the Server has Access. Cannot run server scripts from the StarterGui (Client based). Handles logic of the game doesn't interfere with the world.

Workspace: Items replicate to the Client from Server (but not vice versa). Where you can place various objects for 3d rendering. The only place they can physically interact with the world. Objects not currently needed store in ReplicatedStorage or ServerStorage.

Local Scripts: Client needs access to these. Cannot run in the Workspace. LocalScripts can be put into the StarterGui. StarterGUI replicates to the Client. All Guis are preferred to be edited with a Local Script. For StarterGUI when made on server and added to PlayerGui.

StarterPack: Created for adding tools. Can hold scripts with both LocalScripts and Server Scripts inside. This will clone content items to a player's Backpack. Only applied when a player spawns.

StarterPlayerScripts: Run only once for each player. Generally rely on the ContextActionService. (Bind/Unbind functions). Allows adding of scripts to instance of a Player in the PlayersService. Client-side scripts will run here. These can be Local Scripts. LocalScripts and other objects to be copied to the PlayerScripts. Can create special effects on the client.

StarterGui: Used for making interfaces directly on the games viewport. Designed to hold GUI objects for the user. Applied when a character spawns or respawns.

StarterPlayer: LocalScripts and other objects. Used for when a player joins a game. Used when to define additional inputs with ContextActionService. For when a character spawns in the game. Can be used to replace “CameraScript” or “ControlScript” defaults. Each property of the player object is set to the current state. Can be used to control Cthe Camera and movement controls.

PlayerScripts: For scripts to be located inside the players. Contains LocalScripts. Runs code on the client of the Player. Is not accessible to the server.

PlayerGui: Holds a Player's user GUI. Applied when a character spawns or respawns. All contents of StarterGUI are copied into here.

StarterCharacterScripts: Scripts to add to each player’s character every time they spawn. These do not persist after a character respawns. Allows you to add scripts to the player's Character instance. These can be both Local and Server Scripts.

Scripts: Lua code container that will run its contents on the server. A descendant of the Workspace or ServerScriptService. Has access to server-side objects, properties and events. Actions taken by LocalScripts not replicated will not be visible to Scripts.

LocalScripts: Lua code on a client connected to a Roblox server. They are used to access client-only objects. Only works in Backpack Tools, Character model, PlayerGui, PlayerScripts, ReplicatedFirst.

Module Scripts: These scripts are run only when they are required. Place these in ReplicatedStorage or ServerStorage.

0
I've updated my post to be more of a list, if it helped, you can accept the answer SerpentineKing 3885 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Reference Log

Client refers to the Player (intended audience)

Server refers to the game's server

Server Script = Script

ReplicatedFirst, ReplicatedStorage and ServerStorage

First let me preface a few things involving these. These three are all meant to contain items

ReplicatedFirst

Function

If I placed a script here (generally a LocalScript) then it would run before all other items were loaded

Script Type

Local Scripts Preferred / Module Script

Information

This is the only place you can use the game.Loaded event

ServerStorage

Function

Contains all items for the Server to access, and is NOT replicated to the Client

Script Type

Server Script / Module Script (Server-Side Only)

Information

Generally keeps item models, maps, etc.

ReplicatedStorage

Function

Contains items for both the Server and Client to access

Script Type

Local Scripts / Module Script

Information

Generally RemoteEvents will go here

Server Scripts

Server Scripts need to be placed in areas where the Server has Access.

NOTE: These CANNOT be run from the StarterGui, they can be placed there, but the code will not execute for Guis (which are client based)

Workspace

Function

Used to contain assets you want loaded into the game that will be immediately visible to a player

Script Type

Server Scripts Only

Information

Many people place their scripts here because you could simply use script.Parent to change an item where the script's parent is the item you want to add some code to.

All items in the Workspace are replicated to the Client from the Server (but not vice versa).

ServerScriptService

Function

Holds Scripts to be used in your game.

Script Type

Server Scripts Only

Information

This option is preferred . The reason for this is that you won't have the script duplicated (one on the server and one on the client, where it only runs on the server) and you can organize your work better. The only downside is that you'll need to define parts specifically when placing them here, which is the same for any script calling an instance that is not its parent

For example, if I have a part named "Block" in the workspace, I could place a script under the part and write

local part = script.Parent

or if the script was in the Workspace, I'd write

local part = script.Parent.Block

OR

local part = workspace.Block

OR

local part = game.Workspace.Block

OR

local part = game:GetService("Workspace").Block

If I were to use the ServerScriptService then I would have to write

local part = workspace:WaitForChild("Block")

NOTE: WaitForChild() is not necessary on the Server, but it is needed on the Client, used to make sure items exist before using / adjusting them

Local Scripts

Local Scripts need to be placed in areas the Client has access to

NOTE: These CANNOT be run in the Workspace, they can be placed there, but the code will not be executed.

StarterGui

Function

Contains GUIs to be visible or activated for each individual Client.

Script Type

Local Scripts Only

Information

I prefer to place most LocalScripts here since this will always be replicated to the Client and All Guis are preferred to be edited with a LocalScript

You can ONLY edit GUIs with a Server Script when the gui was made on the server and added to the player's PlayerGui

Starter PlayerScripts / CharacterScripts / Pack

StarterPack

Function

Meant to contain tools you want a player to have when they join the game

Script Type

Local Scripts or Server Scripts (inside of the tools, not the Service)

Information

This will clone items to a player's Backpack

StarterPlayerScripts

Function

Allows you to add scripts to the instance created of the Player in the Players Service

Script Type

Local Scripts Only

Information

These can be Local Scripts and generally rely on the ContextActionService

StarterCharacterScripts

Function

Allows you to add scripts to the player's Character instance

Script Type

Both Local and Server Scripts

Module Scripts

Function

Used to carry out a function you want run multiple times without repeating your code, or if the code should only be run in certain situations.

Information

These scripts are run only when they are required

local module = require(game:GetService("ReplicatedStorage"):WaitForChild("ModuleScript"))

I'd place these in ReplicatedStorage so both the Server and the Client have access to them, though if only the server required access then you could just use the ServerStorage

Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
SerpentineKing's answer summarized:

ReplicatedFirst?
Local Scripts.
Game.Loaded event only place!
GUI Loading Screens.
The earliest possible point.
Objects should be parented to it.
ReplicatedStorage for Objects that don't need loading first.

ServerStorage:
All items for the Server to access.
NOT replicated to the Client. 
Used for item models, maps, etc. 

ReplicatedStorage: 
Both the Server and Client to access. 
RemoteEvents generally go here. 

ServerScriptsService: 
Scripts placed here run both on server and client. 
Placed in areas where the Server has Access. 
Cannot run server scripts from the StarterGui (Client based). 

Client based scripts example: 
WaitForChild(). 

Workspace: 
Items replicate to the Client from Server (but not vice versa). 

Local Scripts: 
Client needs access to these. 
Cannot run in the Workspace. 
LocalScripts can be put into the StarterGui. 
StarterGUI replicates to the Client. 
All Guis are preferred to be edited with a Local Script. 
For StarterGUI when made on server and added to PlayerGui. 

StarterPack: 
Created for adding tools. 
Scripts with both LocalScripts and Server Scripts inside. 
This will clone items to a player's Backpack. 

StarterPlayerScripts: 
Generally rely on the ContextActionService. 
Allows adding of scripts to instance of a Player in the PlayersService. 
These can be Local Scripts. 


CharacterScripts, 
Allows you to add scripts to the player's Character instance. 
These can be both Local and Server Scripts. 

Module Scripts: 
These scripts are run only when they are required. 
require(game:GetService...) 
Place these in ReplicatedStorage or ServerStorage. 
0
Why all in Lua? proqrammed 285 — 5y

Answer this question