Reference

Understanding Script Types

Choose between ServerScripts, LocalScripts, and ModuleScripts before asking NexusRBX AI to generate Roblox code.

Updated July 16, 20263 min read

Guide

This page explains the main Roblox script types in beginner-friendly terms.

ServerScript

ServerScripts run on the Roblox server. They are used for game logic that should be trusted and shared across players.

Use ServerScripts for:

  • leaderstats.
  • rewards.
  • DataStore saving.
  • server-side combat rules.
  • secure shop checks.
  • RemoteEvent handlers.

Common locations:

  • ServerScriptService.
  • Workspace for specific objects when appropriate.

Example prompt:

texttext
Create a ServerScript for ServerScriptService that creates leaderstats with Coins and Wins when a player joins.

LocalScript

LocalScripts run for an individual player. They are used for player-specific behavior such as UI, camera, input, and local effects.

Use LocalScripts for:

  • UI buttons.
  • player input.
  • camera effects.
  • local animations and effects.
  • client-side RemoteEvent requests.

Common locations:

  • StarterPlayerScripts.
  • StarterGui.
  • StarterCharacterScripts.
  • Tools.

Example prompt:

texttext
Create a LocalScript inside StarterGui that opens ShopFrame when OpenShopButton is clicked.

ModuleScript

ModuleScripts store reusable code that other scripts can require.

Use ModuleScripts for:

  • shared configuration.
  • reusable functions.
  • item data.
  • ability definitions.
  • utility code used by multiple scripts.

Common locations:

  • ReplicatedStorage for shared client/server modules.
  • ServerScriptService for server-only modules.

Example prompt:

texttext
Create a ModuleScript named ItemConfig in ReplicatedStorage that stores item prices and display names. Also show how a ServerScript can require it.

Quick Comparison

Script typeRuns whereBest forCommon mistake
ServerScriptServerSecure game logic and shared systemsTrying to control player UI directly.
LocalScriptPlayer clientUI, input, camera, local effectsPlacing it somewhere it will not run.
ModuleScriptRequired by other scriptsReusable code and dataExpecting it to run by itself.
Spot something unclear?

Send the page title and link to support so the report reaches the right context.

Report an issue with this page