A Script is a Lua file that runs on the server. It can control parts, detect player actions, give tools, and more โ but it doesnโt run on the client side.
Example:
print("Server started")
workspace.Part.BrickColor = BrickColor.new("Bright red")
๐ Place Scripts in: ServerScriptService
, Workspace
, or Tools
.
A LocalScript runs on the playerโs device (client). It is used to control UI, camera, mouse, and local input.
Example:
script.Parent.Text = "Hello " .. game.Players.LocalPlayer.Name
๐ Place LocalScripts in: StarterGui
, StarterPlayerScripts
, StarterPack
, Character
.
A ModuleScript contains reusable functions or data and can be required by Scripts or LocalScripts.
Example:
-- ModuleScript
local module = {}
function module.sayHi()
print("Hi from module!")
end
return module
-- Script or LocalScript
local myModule = require(game.ServerScriptService.MyModule)
myModule.sayHi()