Menu
CoddyTech

Paint a Part

Part of the Roblox Game Scripting section of Coddy's Lua journey. Lesson 2 of 24.

A part has properties: its color, what it is made of, how see-through it is, its size and where it is. Changing a property changes the part in the game at once.

A script that sits inside a part reaches that part through script.Parent. Store it in a variable so you can use it on every line:

local block = script.Parent
block.Color = Color3.fromRGB(0, 120, 255)

local block creates a variable named block, and = puts a value in it. Color3.fromRGB mixes a color from red, green and blue, each from 0 to 255, so 0, 120, 255 is a bright blue.

Some properties take a value from a list Roblox gives you, called an Enum. The material is one of them:

block.Material = Enum.Material.Wood

Transparency is a number: 0 is solid, 1 is invisible, and anything in between is see-through.

challenge icon

Challenge

Easy

The script is inside the gray block. Change three of its properties:

  1. Make it red: Color3.fromRGB(255, 0, 0)
  2. Make it glow: the material Neon
  3. Make it half see-through: Transparency of 0.5

Press Play to see it, then Check.

Try it yourself

local block = script.Parent

-- 1. Make the block red

-- 2. Make it glow

-- 3. Make it half see-through
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Roblox Game Scripting

Practice on your own: Online Lua compiler