# Roblox files Roblox models and places (`.rbxm` / `.rbxl` binary, `.rbxmx` / `.rbxlx` XML) load as an **`RbxTree`**: instances with a class name, a name, typed properties and children. Roblox meshes (`.mesh`) load as an ordinary [`Scene`](scene.md). This is a file library, not a Roblox runtime. It never creates Instances. A Roblox game that wants Instances walks the tree itself, and the tree works the same under LuaJIT and the luau CLI. ```luau local place = assert(F.load(placeBytes)) -- binary .rbxl -> RbxTree assert(place.kind == "rbxtree" and place.place) -- a place: the roots are services for inst, depth in F.Rbx.descendants(place) do print(string.rep(" ", depth - 1) .. inst.className .. " " .. inst.name) end local step = assert(F.Rbx.find(place, "Workspace/Course/Step2")) local size = F.Rbx.get(step, "size") -- { 4, 1, 4 } (the binary name of Part.Size) assert(size[1] == 4 and size[2] == 1) local xml = assert(F.convert(placeBytes, "rbxlx")) -- binary -> XML: both read and write the same tree assert(F.detect(xml) == "rbxlx" and F.detect(placeBytes) == "rbxl") ``` ## The tree `F.Rbx` (`codecs/model/Rbx`) holds the type and its helpers: | Field / call | Meaning | |---|---| | `tree.roots` | the top-level instances (the services of a place) | | `tree.place` | true for `.rbxl` / `.rbxlx` (services); saving to `rbxl` sets it | | `tree.metadata` | the file's META entries (`ExplicitAutoJoints`, ...) | | `inst.className`, `inst.name`, `inst.children`, `inst.parent` | the hierarchy. `Name` is `inst.name`, not a property | | `inst.properties[name]` | `{ type = "Vector3", value = { x, y, z } }` | | `F.Rbx.tree()`, `instance(class, name)`, `add(parent, child)` | build trees | | `set(inst, name, type, value)`, `get(inst, name)` | properties | | `find(root, "A/B/C")`, `descendants(root)`, `list(tree)`, `fullName(inst)` | lookups | Property values keep the file's type, because a number alone could be an `Int32`, a `Float32` or an `Enum`. Arrays follow the argument order of the Roblox constructors, so `Vector3.new(table.unpack(v.value))` and `CFrame.new(table.unpack(v.value))` rebuild them in a game. The full list is in the header of `src/Rosetta/codecs/model/Rbx/init.luau`: - **Text and numbers:** `String`, `BinaryString`, `ProtectedString`, `ContentId`, `SharedString` are strings. `Bool`, `Int32`, `Int64`, `Float32`, `Float64`, `Enum`, `BrickColor`, `Faces` and `Axes` are numbers and booleans. - **Arrays:** `Vector2`, `Vector3` and `Color3` (0..1) are arrays. `CFrame` is 12 numbers: the position, then the rotation row by row. - **References:** `Ref` and the object form of `Content` hold the instance itself. `Content` is otherwise a URI string, or nil. - **Unknown data** is kept, not dropped: properties of unknown types (`Raw` in binary files, `XmlRaw` in XML) and unknown chunks are written back unchanged. Property names are the ones the file stores. Binary files use a few serialized names, for example `size` for `Part.Size` and `Color3uint8` for `Part.Color`. Without Roblox's reflection database, the library does not rename them. ```luau local tree = F.Rbx.tree() local model = F.Rbx.add(tree, F.Rbx.instance("Model", "Tower")) for i = 1, 3 do local part = F.Rbx.add(model, F.Rbx.instance("Part", "Floor" .. i)) F.Rbx.set(part, "size", "Vector3", { 8, 1, 8 }) F.Rbx.set(part, "CFrame", "CFrame", { 0, i * 4, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1 }) F.Rbx.set(part, "Anchored", "Bool", true) end F.Rbx.set(model, "PrimaryPart", "Ref", model.children[1]) local rbxm = assert(F.save(tree, nil, { format = "rbxm" })) -- LZ4 chunks; { compression = "none" } writes them raw local back = assert(F.load(rbxm)) assert(F.Rbx.get(back.roots[1], "PrimaryPart") == back.roots[1].children[1]) local text = buffer.tostring(assert(F.save(back, nil, { format = "rbxmx" }))) assert(string.find(text, '