Learn Roblox Scripting (Luau) from Zero
Scripting is what brings Roblox games to life. Every mechanic — from a kill brick to a complex combat system — is powered by Luau scripts. This tutorial takes you from zero coding knowledge to writing practical game scripts.
Basics: Variables and Print
local playerName = "Alex"
local score = 100
local isAlive = true
print("Player:", playerName)
print("Score:", score)
Functions
local function greetPlayer(name)
print("Welcome, " .. name .. "!")
end
greetPlayer("Alex") -- prints: Welcome, Alex!
Events — The Heart of Roblox Scripting
Roblox is event-driven. Things happen when players touch parts, click buttons, or join the game.
-- When a player touches a part
script.Parent.Touched:Connect(function(hit)
print(hit.Name .. " touched me!")
end)
5 Practical Scripts
Script 1: Kill Brick
script.Parent.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid.Health = 0
end
end)
Script 2: Speed Boost Pad
script.Parent.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid.WalkSpeed = 50
task.wait(5)
humanoid.WalkSpeed = 16
end
end)
Script 3: Disappearing Platform
local part = script.Parent
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
task.wait(1)
part.Transparency = 1
part.CanCollide = false
task.wait(3)
part.Transparency = 0
part.CanCollide = true
end
end)
Script 4: Coin Collector
local coin = script.Parent
coin.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local stats = player:FindFirstChild("leaderstats")
if stats then
stats.Coins.Value += 1
coin:Destroy()
end
end
end)
Script 5: Door with Key
local door = script.Parent
local requiredCoins = 10
door.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local coins = player.leaderstats.Coins
if coins.Value >= requiredCoins then
door.Transparency = 0.5
door.CanCollide = false
task.wait(3)
door.Transparency = 0
door.CanCollide = true
end
end
end)
Skip the Coding — Use AI
If scripting isn't your thing, Obby writes all the Luau code for you. Describe what you want and the AI generates working scripts instantly.


