🧱 ROBLOX LUA NOTES – ADDING OBJECTS


πŸ“Œ What is Instance.new()?

Instance.new() is used to create new objects (parts, lights, sounds, scripts, etc.) with code.

lua
CopyEdit
local part = Instance.new("Part")

This creates a new Part, but it doesn’t appear in the game world until you parent it to something.


🧩 STEP 1: Create the object

lua
CopyEdit
local part = Instance.new("Part")


🧲 STEP 2: Set its parent

This adds it to the game world (like putting it in Workspace).

lua
CopyEdit
part.Parent = game.Workspace

OR create and parent it in one line:

lua
CopyEdit
local part = Instance.new("Part", game.Workspace)


πŸ› οΈ STEP 3: Customize it

Set its properties (position, size, color, etc.)

lua
CopyEdit
part.Anchored = true
part.Position = Vector3.new(0, 10, 0)
part.Size = Vector3.new(4, 1, 4)
part.Material = Enum.Material.Neon
part.Color = Color3.new(1, 0, 0)  -- red