โ† All guides
2025-05-03ยท8 min read

Roblox Scripting for Beginners: Complete 2025 Guide

New to Roblox Studio scripting? This beginner guide covers Luau basics, where to put scripts, and your first working scripts with copy-paste examples.

What Language Does Roblox Use?

Roblox uses Luau โ€” a fast, typed dialect of Lua 5.1 developed by Roblox. If you've seen Lua tutorials online, most of it applies to Roblox scripting too.

Where Do Scripts Go?

This is the most confusing part for beginners. There are three main places:

ServerScriptService โ€” Scripts here run on the server. Use these for game logic, saving data, handling purchases, and anything security-sensitive. Players cannot see or edit these.

StarterPlayerScripts โ€” LocalScripts here run on each player's computer. Use these for GUIs, input handling, and visual effects.

StarterGui โ€” LocalScripts for your GUI elements go here.

Inside Parts โ€” You can put a Script directly inside a Part in the workspace. Good for simple things like kill bricks.

Your First Script: Make a Part Glow

Put a Script inside a Part in the workspace:

local part = script.Parent
local light = Instance.new("PointLight")
light.Brightness = 5
light.Range = 20
light.Parent = part

script.Parent refers to whatever the script is inside โ€” in this case, the Part.

Variables and Data Types

local playerName = "Alex"        -- string
local score = 100                -- number
local isAlive = true             -- boolean
local nothing = nil              -- nil (empty/no value)

Always use local for variables. Global variables in Roblox can cause hard-to-find bugs.

If Statements

local score = 50

if score >= 100 then
    print("You win!")
elseif score >= 50 then
    print("Almost there!")
else
    print("Keep going!")
end

Functions

local function greetPlayer(player)
    print("Welcome, " .. player.Name .. "!")
end

game.Players.PlayerAdded:Connect(greetPlayer)

... joins strings together. :Connect() wires an event to a function โ€” so every time a player joins, greetPlayer runs.

Loops

-- Repeat 5 times
for i = 1, 5 do
    print("Count: " .. i)
end

-- Loop forever (use task.wait to avoid lag)
while true do
    task.wait(1)
    print("One second passed")
end

Always use task.wait() in while loops. A loop without a wait will freeze Roblox Studio instantly.

Getting Services

Almost everything in Roblox goes through services:

local Players       = game:GetService("Players")
local TweenService  = game:GetService("TweenService")
local DataStoreService = game:GetService("DataStoreService")

Common Beginner Mistakes

Lowercase API names โ€” Roblox APIs are case-sensitive. findFirstChild won't work, FindFirstChild will.

Missing nil checks โ€” Always check if something exists before using it. if player.Character then before accessing the character.

Script in the wrong place โ€” If your script isn't working, check where it is. A LocalScript in ServerScriptService won't run. A regular Script in StarterGui won't work either.

Next Steps

Once you're comfortable with the basics, check out our free script library. Copy working scripts, read through them, and modify them for your game. Learning by editing real code is faster than any tutorial.

Ready-made scripts for your game

Browse our free library of copy-paste Luau scripts โ€” no setup needed.

Browse Script Library โ†’
More guides
How to Make a Roblox DataStore (Save Player Data)6 min read โ†’How to Make a Roblox Shop System (Buy Items with Cash)7 min read โ†’Roblox NPC Scripting Guide: Pathfinding, Dialogue & More7 min read โ†’