[Question] Difference between the Script types

Hello, Devforum community!

As the title already mentions I wanted to ask about what the difference of all of these script types are and when it would be perfect to use it.

I am still kind of new to Roblox Scripting and the programming language Lua.

I couldn’t find any post that explains each type properly so I wanted to ask you guys about the differences between the Script, the Local Script and the Module Script.

What I know about the Script and Local Script so far is that the Script would be a Server-Side thing and the Local Script being a Client-Side one, however I don’t really know anything about the Module Script and when I could use that.

I hope you guys can help me!
Thank you in advance! :slight_smile:

1 Like

So how a game works is that the server, in this case, Roblox, streams the content to the client, you. Think of this like a stream, the streamer is the server and you are the client.

Whenever the streamer does something, it replicates to all clients, meaning that everyone can see it, but lets say you open a tab, no one will see except for you.

This is what local and server scripts do. Server scripts replicate to everyone, while local scripts just changes whatever is on your screen.

1 Like

This is everything you need to know about ModuleScript.

The Roblox Developer Hub should be your go to source of information. Create a topic if you can’t find it there or have a specific problem with your script.

1 Like

LocalScripts have almost all functionalities of a regular script and everything only happens for the player who the localscript is ran for. For example,

local name = "lexishh"
local Players = game:GetService("Players")
user = Players.LocalPlayer
if user.Name == name then

This would remove a door only for lexishh.

Serverscripts are regular scripts, if they are ran, they happen to everyone.

Local Scripts are scripts that can be used to get in contact with the client, or player.

Scripts can be used to access server-sided things.

ModuleScripts are used to reference and use scripts you’ve made, this helps in not repeating yourself (convenience). Like @Razinox mentioned, you should make sure to read things on here. Get used to searching up terms and looking at API references.

This video provides a descriptive presentation on how Local and Server works. Try checking it out and see if it helps.

I recommend learning about the Client-Server model first.

Script is the server sided one (Things in server happens in every client as example happens in every “PC”, “mobile”, “video games”). Its good for handling things such as data store and changing values, Its good to prevent some exploiters since they cant edit server scripts nor even see them or delete.

Local scripts can be edited by exploiters but it is needed for some things such as UIS, input service, things that happen in your device (Its the client sided, it doesnt replicate EVERYTHING to the server, there are some things that does it but yeah they are most likely things that happen in your device, those who replicated to the server happens in everything)

Module scripts are scripts where you organize things that you dont really need but its really good, they help organize things that you are going to probably use in other scripts (Codes that repeat such as doing while true do – if then – for loop at a thing BUT with the same objective)

A example for when module is useful is when you want to do a data store “module” so you create the data store in it and you can send the data to save in other scripts by referencing the module.

Summary: Scripts are server sided codes
Local scripts are client sided
Module scripts are organization

I would probably have similar answers to what the people said above, but I just want to add that you can use a RemoteEvent or RemoteFunction to communicate between client and server. So let’s say a server handled a round-based game - when the round starts, it displays a countdown to all the clients in the game. The server is handling the round while it fires RemoteEvents to each client, telling them what the time left is.

Those are all helpful answers! I will check out these links tomorrow - thank you guys! ^^