BasePart/CFrame of the
Model/PrimaryPart. All other parts in the model will also be moved and will maintain their orientation and offset respective to the
Note, this function will throw an error if no
Model/PrimaryPart exists for the model. This can cause issues if, for example, the primary part was never set or has been destroyed. Therefore, it is recommended the developer check the
Model/PrimaryPart exists before using this function. For example:
if model.PrimaryPart then model:SetPrimaryPartCFrame(cf) end
A common use for this is for the ‘teleportation’ of player characters to different positions.
In this code sample a Model is created with a simple arrangement of Parts. The PrimaryPart of this Model is then set, meaning Model:SetPrimaryPartCFrame can then be used.
To demonstrate SetPrimaryPartCFrame, a simple loop is then run which switches the model between two CFrames every second.
In this sample every Player character Model added will be moved to 0, 500, 0 three seconds after spawning.