How to use BulkMoveTo()

I read WorldRoot | Roblox Creator Documentation I only understand that it moves parts to a position. I have 0 idea on how to use it.

1 Like

you need a list of parts, and a list of cframes corresponding to each part.

By list of parts do you mean table?

workspace:BulkMoveTo(workspace.Part1, workspace.Part2, workspace.Part3, workspace.Goal.Position)

Basically,

local Parts = {workspace.Part1,workspace.Part2}
local Positions = {CFrame.new(0,50,0),CFrame.new(0,60,0)}
workspace:BulkMoveTo(Parts,Position)

Part1 will go to (0,50,0) and Part2 will go to (0,60,0)

5 Likes

One small thing, but I recommend using __newindex methamethod for this case in the positions metatable, as you don’t need to bother to table.remove indexes, making your script more efficient. Because:

function createObject()
     return  {
      CFrame = CFrame.new() -- some trickery
     }
end

local objects = {createObject()} --< custom table object
local toMove = {objects[1]} --< referncing the object so the RAM index stays the same.
local mt = {__newindex = function(tab,index) -- <--- It will be iterated because the loop checks only parts, 
--and you can set a metatable for __index "CFrame" being changed inside of the object
 return toMove[index].CFrame
}
local positions = {}
setmetatable(positions,mt)
workspace:BulkMoveTo(toMove,positions)
table.remove(toMove,1)