Where Roblox Scripts Run and How to Debug Them
Learn to choose a Script, LocalScript or ModuleScript and use Studio Output to catch setup mistakes.
Run a tiny test first
Open Explorer and Output from the View ribbon in a new baseplate. Put a Script in ServerScriptService and add print("Server ready"). Press Play and check the server messages. Next, put a LocalScript in StarterPlayerScripts with print("Client ready"). In a two-client test, the server prints once while each client prints separately. That difference shows who owns the code.
Put shared logic in a module
A ModuleScript returns a value when another script calls require. Put shared modules in ReplicatedStorage when both server and client need them. Keep server-only rules and private state in ServerScriptService. A shared module can run on both sides, but each side has its own state.
Debug the first error
Check the first red message in Output and click its line number. An infinite-yield warning usually means an object was named differently or placed under the wrong parent. Fix the hierarchy or wait for objects that really replicate later. Test again with Output open.
Build a three-script test rig
Create a fresh baseplate and name the place Script Lab. In Explorer, add a Script named LabServer inside ServerScriptService and a LocalScript named LabClient inside StarterPlayerScripts. Put a ModuleScript named LabConfig inside ReplicatedStorage. Give each entry script one distinctive print message. Start with Play, which gives Studio reason to create a player and run the local entry point. The two logs tell you more than the absence of an error: they prove that both scripts reached the lines you intended. Write down what you expect to see before starting. If one print is missing, isolate the script that owns it before checking any gameplay code.
Run a small configuration example
Copy this into LabConfig. Both sides can read this configuration because it is safe to share. Freezing the table also turns an accidental edit into an error at the line that tried to change it. A module is evaluated on first use in a given execution context. Shared source does not imply shared runtime values across the network. Even with an unfrozen table, setting a field on the local copy would not update the copy held by the server.
-- ReplicatedStorage.LabConfig
return table.freeze({ CourseName = "Training Yard", MaxLaps = 3 })
Add this to both LabServer and LabClient. Change the final print prefix to CLIENT in the LocalScript. When both prefixes appear, you have verified that the two execution contexts can find and require the module.
local storage = game:GetService("ReplicatedStorage")
local config = require(storage:WaitForChild("LabConfig"))
print("SERVER", config.CourseName, config.MaxLaps)
Make two deliberate mistakes
Stop the test and rename LabConfig to WrongName. Run again and watch Output for a message that mentions a long wait. The entry points wait for a name that will never arrive. Restore the original name and confirm that the configuration prints return. Now add a line in LabClient that assigns a new value to MaxLaps. The frozen table gives you a different type of error, one with a specific failing line. Remove it afterward. Compare these two failures: a script can be running but waiting for data, or it can have encountered an error that prevented later lines from running. Distinguishing those cases tells you whether to inspect the hierarchy or inspect a calculation.
Inspect the live hierarchy in a multiplayer test
Use Studio's test controls to start a server and two players. Locate LabClient under each player's PlayerScripts while the simulation runs. StarterPlayerScripts is the template in the edit hierarchy, while PlayerScripts is the running copy. Return to the edit session before changing the template. In the server viewport, check that the server logged its initialization once. In each player viewport, find the client log. If a script behaves differently from what you expected, record which view produced the error before changing code. That one detail can distinguish an unavailable object from a typo. Repeat the test after fixing the issue and check both contexts again.
Apply this split in a real mechanic
Imagine a course timer on the HUD. The server owns the start time and decides when a finish counts. A LocalScript formats elapsed seconds and updates the label. LabConfig can hold display settings such as the number of decimal places. The timer never needs to trust a value supplied by the HUD. Try extending the lab with a StringValue or an attribute from the server and display a read-only copy on the client. Before moving a script to resolve an error, ask which side really owns the behavior. A mechanic that only affects a menu can be local. A decision about which player earned something belongs where every player gets the same result.