What a script actually is, the difference between Scripts and LocalScripts, and how instructions run top to bottom.
In the last lesson you made a print a message. That was a tiny list of instructions that Roblox read once, from top to bottom, when the game started. That's all a is.
This lesson is about where live and which one runs where — because Roblox is not one computer running your game. It's two.
When someone plays your game, there are actually two copies of the game running:
That's why there are two kinds of :
| Script type | Runs on | Used for |
|---|---|---|
| Script | The server | Game rules, money, things every player must agree on |
| LocalScript | One player's computer | The player's own screen, controls, and feel |
A LocalScript runs on…
execute top to bottom, one line at a time. This :
local part = workspace.Baseplate
print("Found the baseplate")
part.Anchored = false
means: grab the baseplate, tell me when you've done it, then let it fall. Order matters — if you wrote part.Anchored = false before defining part, the would error, because it doesn't know what part is yet.
You already know the Output window from the last lesson. print is how you watch your work line by line. Use it freely — real developers leave print statements in code all the time while they're building.
Look at this line:
local part = workspace.Baseplate
workspace means the folder (remember: the game world)..Baseplate means "the object inside it named Baseplate".So this line reads: "get the object named Baseplate, which lives in , and call it part."
There's another way to find things that matters a lot: a can look at its own place in the world.
local parent = script.Parent
script is a 's name for itself, and script.Parent is whatever folder or object that is sitting inside. Developers use this constantly — the moves with its parent and always finds what it's attached to.
A Script named 'CoinScript' sits inside a part named 'Coin'. What does script.Parent give you? local parent = script.
A in ServerScriptService runs when the game starts. A LocalScript in StarterPlayer > StarterPlayerScripts runs for each .
For the rest of this section, put everything in ServerScriptService unless a lesson says otherwise — it keeps server code and client code separate, and you'll build from there.
You want a line that grabs the script's own parent so the script can find whatever it's attached to. Write the assignment using script.
-- find your own parent
PlayerAdded later.workspace.Baseplat errors. The Output tells you exactly which line — believe it.Next up: making remember things with .