BETA mahshid.de is still being built – things may change or wobble.Still under construction. Feedback
DE
Lesson 4 of 11 · Scripting

Variables and properties

With code you can change everything you see in the Properties panel: colour, transparency, size … Variables remember things for you along the way.

What you’ll learn

  • find a part in code
  • change properties with code
  • create variables with local

Variables: names for things

With local you give something a name. After that you can use the name instead of the long path. Rename your part in the Explorer to MyPart first.

Change properties

After the dot you write the name of the property – exactly as it appears in the Properties panel.

local part = workspace.MyPart

part.BrickColor = BrickColor.new("Bright red")
part.Transparency = 0.5   -- 0 = visible, 1 = invisible
part.Anchored = true

local height = part.Size.Y
print("The part is " .. height .. " studs tall")

Upper and lower case matter

workspace.mypart does not find MyPart. Watch the spelling carefully – it is the most common beginner mistake. The Output then shows a red error message with the line number.

🛠️ Try it

Make your part turn blue and half transparent with a script. Bonus: print its width (Size.X) to the Output.

🧠 Mini quiz

What does local colour = "Red" do?

What does Transparency = 1 mean?

Roblox and Roblox Studio are trademarks of the Roblox Corporation. mahshid.de is not affiliated with Roblox. All links to Roblox lead to the official sites.