What you'll make: a part that changes color by itself, and a classic kill brick. About 20 minutes.
1. Set up Studio
- Open Roblox Studio and create a new Baseplate.
- Open View β Explorer, View β Properties and View β Output. You'll use these all the time.
- On the Home tab, click Part. A grey block appears.
- In the Explorer, hover over the new Part, click the + and choose Script.
The script is now a child of the part. That matters in a minute.
2. Hello, world
Delete whatever is in the script and type:
print("Hello from PLUVOX!")
Press Play (or F5). Look in the Output window β your message is there. print is your best debugging friend: whenever something doesn't work, print stuff to see what's happening.
3. Variables
A variable is a labelled box that holds a value. In Luau you make one with local:
local playerName = "Andreas" -- string (text) local coins = 50 -- number local isVip = true -- boolean (true/false) coins = coins + 25 print(playerName .. " has " .. coins .. " coins")
The .. joins text together. This prints Andreas has 75 coins. Lines starting with -- are comments; Roblox ignores them.
4. Change a part with code
script.Parent means "the thing this script is inside" β our Part. Everything you see in the Properties window can be changed with code:
local part = script.Parent part.Anchored = true part.Size = Vector3.new(8, 1, 8) part.Color = Color3.fromRGB(255, 93, 143) part.Material = Enum.Material.Neon
Anchored parts don't fall or get pushed. Almost every part in your map should be anchored.
5. Loops: make it party
A while true do loop repeats forever. task.wait() pauses so the game doesn't freeze β never leave it out of an endless loop.
local part = script.Parent part.Anchored = true while true do part.BrickColor = BrickColor.random() task.wait(0.5) end
Press Play. Your part now changes color every half second. π
6. Events: the kill brick
Events let your code react when something happens. Touched fires whenever something touches the part. We check if it was a character (it has a Humanoid) and set its health to 0.
local part = script.Parent part.Anchored = true part.Color = Color3.fromRGB(255, 60, 60) part.Touched:Connect(function(hit) local humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid") if humanoid then humanoid.Health = 0 end end)
hit is the body part that touched (like a leg). Its Parent is the whole character, which is where the Humanoid lives. Walk onto your brick and⦠oof.
Other parts can touch your brick too. Without the if humanoid check, the script would error trying to change health on something that has none.
π Challenge
Make a "checkpoint" pad: when a player touches it, the pad turns green and the Output prints [name] reached the checkpoint!
Need a hint?
Get the player from the character with game.Players:GetPlayerFromCharacter(hit.Parent). If it isn't nil, use player.Name.
Show solution
local pad = script.Parent pad.Anchored = true pad.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then pad.Color = Color3.fromRGB(75, 216, 139) print(player.Name .. " reached the checkpoint!") end end)
You'll notice it prints many times β Touched fires for every body part. In Module 2 you'll learn a debounce to fix that.
You just used variables, properties, loops and events: the core of every Roblox game. Keep going with the full course.