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 = workspaceA 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
EasyThis 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.
- Name it
Platform. - Give it the Size
6, 1, 28and the Position0, 10, 0. - Add a line so it does not fall.
- 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
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Roblox Game Scripting
2Loops and Functions
Row of PillarsStaircase BuilderTower BuilderCoin FactoryBlinking LightVanishing Bridge5Your First Game
Your First ObbyPractice on your own: Online Lua compiler