Menu
CoddyTech

Build a Platform

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

Scripts can build the world too. Instance.new makes a new object, and you set its properties before you put it in the game:

local ball = Instance.new("Part")
ball.Name = "Ball"
ball.Shape = Enum.PartType.Ball
ball.Position = Vector3.new(0, 20, 0)
ball.Parent = workspace

A new part is not in the world until its Parent is set to workspace. Setting Parent last means the part shows up already finished.

A new part is also not anchored: gravity pulls it down and it falls. The ball above drops from height 20 onto the ground. A part with Anchored = true stays exactly where you put it, which is what you want for floors, walls and platforms.

challenge icon

Challenge

Easy

This time there is no bridge at all. Your script runs in ServerScriptService and builds one. It already makes a new Part and sets three of its properties, with the wrong values.

  1. Name it Platform.
  2. Give it the Size 6, 1, 28 and the Position 0, 10, 0.
  3. Add a line so it does not fall.
  4. Add a line that puts it in the world.

Write the new lines like the ones above them: platform., the property, = and the value. Capital letters matter: Anchored, not anchored. Press Play and cross it, then Check.

Try it yourself

local platform = Instance.new("Part")

-- 1. Name it Platform
platform.Name = "Part"

-- 2. Size and Position
platform.Size = Vector3.new(4, 1, 2)
platform.Position = Vector3.new(0, 0, 0)

-- 3. Keep it from falling

-- 4. Put it in the world
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