Codectionary / Developer documentation / Luau

Luau table slice copying

table.move copies an integer-keyed range into another position and supports overlapping ranges. It is available in Luau and Lua 5.3+, but not the original Lua 5.1 library.

Syntax

table.move(source, first, last, destinationStart, destination)

Examples

Luau table slice copying

Run as a standalone current Luau script, or as a Script in Roblox Studio ServerScriptService. No Roblox engine APIs are required; type-annotated syntax is not standard Lua.

local source = {"a", "b", "c", "d"}
local page = {}
table.move(source, 2, 3, 1, page)
print(table.concat(page, ","))
print(table.concat(source, ","))
  1. Output: b,c then a,b,c,d. The source is unchanged because a separate destination was supplied.

Best practices

  • Validate source and destination bounds. Nested table values are shared references rather than deep copies.

Runtime & versions

Luau host; Roblox engine examples require Roblox Studio. Feature availability depends on the language and runtime version used by your project; consult the official reference below.

Luau documentation

Specifications & further reading