Type Index Pages
- BillboardGui
- CanvasGroup
- Frame
- Hint
- ImageButton
- ImageLabel
- PlayerGui
- ScreenGui
- ScrollingFrame
- StarterGui
- SurfaceGui
- TextBox
- TextButton
- TextLabel
- UIAspectRatioConstraint
- UIGradient
- UIGridLayout
- UIListLayout
- UIPadding
- UIPageLayout
- UIScale
- UISizeConstraint
- UITableLayout
- UITextSizeConstraint
- VideoFrame
- ViewportFrame
- ChangeHistoryService
- CoreGui
- DataModelSession
- DockWidgetPluginGui
- MultipleDocumentInterfaceInstance
- Plugin
- PluginAction
- PluginGui
- PluginGuiService
- PluginManager
- PluginMenu
- PluginMouse
- PluginToolbar
- PluginToolbarButton
- QWidgetPluginGui
- Selection
- StandalonePluginScripts
- StatsItem
- StudioService
- StudioTheme
No results found!
-
Instance
- GameSettings
- DebugSettings
- BodyMover
- WeldConstraint
- HttpRbxApiService
- NotificationService
- Translator
- Lighting
- Beam
- GuiService
- UserInputService
- Studio
- Plugin
- HttpService
- Mouse
- BindableEvent
- RunService
- Pages
- Humanoid
- TestService
- PathfindingService
- Chat
- NetworkPeer
- Feature
- CharacterAppearance
- Constraint
- NetworkReplicator
- JointInstance
- Light
- BasePlayerGui
- AnalyticsService
- NetworkMarker
- BinaryStringValue
- FlyweightService
- Geometry
- LoginService
- InstancePacketCache
- ThirdPartyUserService
- TouchInputService
- RuntimeScriptService
- GuidRegistryService
- PartOperationAsset
- DialogChoice
- PhysicsService
- AdService
- TextService
- MarketplaceService
- TeleportService
- Accoutrement
- GamePassService
- AssetService
- InsertService
- PointsService
- ChangeHistoryService
- ServerScriptService
- JointsService
- LogService
- InputObject
- Toolbar
- LuaSettings
- RenderSettings
- AnimationTrack
- PhysicsSettings
- NetworkSettings
- CFrameValue
- Animation
- Color3Value
- BoolValue
- BrickColorValue
- Vector3Value
- AnimationController
- BindableFunction
- Button
- Trail
- LocalizationTable
- LocalizationService
- DebuggerBreakpoint
- DebuggerWatch
- ScriptDebugger
- Animator
- Attachment
- RemoteFunction
- RemoteEvent
- PluginManager
- Camera
- Stats
- Sky
- StarterPlayer
- Dragger
- TerrainRegion
- Path
- TextFilterResult
- Dialog
- StatsItem
- GoogleAnalyticsConfiguration
- ScriptContext
- ControllerService
- CacheableContentProvider
- ReflectionMetadataClasses
- ReflectionMetadataEnums
- DebuggerManager
- GuiBase
- UIBase
- LuaSourceContainer
- GuiItem
- DataModelMesh
- ServiceProvider
- ReflectionMetadataItem
- PostEffect
- PhysicsPacketCache
- TouchTransmitter
- RobloxReplicatedStorage
- Visit
- LuaWebService
- ScriptService
- FlagStandService
- VirtualUser
- SpawnerService
- TimerService
- CookiesService
- Team
- GroupService
- StarterGear
- Message
- PlayerScripts
- Configuration
- ContentProvider
- CollectionService
- Debris
- ReplicatedFirst
- ServerStorage
- ReplicatedStorage
- Folder
- TweenService
- Players
- ContextActionService
- StarterPlayerScripts
- SoundService
- KeyframeSequenceProvider
- VRService
- PluginGuiService
- Player
- Teams
- Pose
- Keyframe
- KeyframeSequence
- IntConstrainedValue
- DoubleConstrainedValue
- ForceField
- RayValue
- Fire
- Smoke
- Sparkles
- ParticleEmitter
- IntValue
- StringValue
- NumberValue
- Explosion
- ObjectValue
- SoundGroup
- UserGameSettings
- ClickDetector
- Sound
- Selection
- BadgeService
- TaskScheduler
- GlobalDataStore
- DataStoreService
- CustomEvent
- CustomEventReceiver
- VirtualInputManager
- FunctionalTest
- TweenBase
- SoundEffect
- ReflectionMetadataEvents
- ClusterPacketCache
- PVInstance
- FaceInstance
- Controller
- ReflectionMetadataCallbacks
- ReflectionMetadataFunctions
- ReflectionMetadataYieldFunctions
- ReflectionMetadataProperties
- ReflectionMetadata
- AdvancedDragger
- HapticService
- FriendService
- GamepadService
No Result Found !!!
SetPrimaryPartCFrame
For thread safety, this property is not safe to read in an unsynchronized thread.
This function has been superseded by PVInstance/PivotTo which acts as a more performant replacement and does not change your code’s behavior. Use PVInstance/PivotTo for new work and migrate your existing Model/SetPrimaryPartCFrame calls when convenient.
Sets the BasePart/CFrame of the Model’s Model/PrimaryPart. All other parts in the model will also be moved and will maintain their orientation and offset respective to the Model/PrimaryPart.
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.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
|
|
The |
Returns
| Return Type | Summary |
|---|---|
Code Samples
SetPrimaryPartCFrame
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.
-- define two CFrames
local startCFrame = CFrame.new(0, 10, 0)
local endCFrame = CFrame.new(0, 15, 0) * CFrame.Angles(0, math.rad(90), 0)
-- create a simple model
local model = Instance.new("Model", game.Workspace)
local part = Instance.new("Part", model)
part.Size = Vector3.new(5, 1, 5)
part.Anchored = true
part.CFrame = startCFrame
part.BrickColor = BrickColor.new("Bright green")
local part2 = Instance.new("Part", model)
part2.Size = Vector3.new(5, 1, 1)
part2.Anchored = true
part2.CFrame = startCFrame * CFrame.new(0, 1, 0) * CFrame.Angles(0, math.rad(90), 0)
part2.BrickColor = BrickColor.new("Bright red")
-- set the model's PrimaryPart
model.PrimaryPart = part
-- loop between the two CFrames
while true do
wait(1)
model:SetPrimaryPartCFrame(startCFrame)
wait(1)
model:SetPrimaryPartCFrame(endCFrame)
end
Character SetPrimaryPartCFrame
In this sample every Player character Model added will be moved to 0, 500, 0 three seconds after spawning.
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(newPlayer)
newPlayer.CharacterAdded:Connect(function(characterModel)
wait(3)
characterModel:SetPrimaryPartCFrame(CFrame.new(0, 500, 0))
end)
end)
How this site use cookies
This Platform uses cookies to offer you a better experience, to personalize content, to provide social media features and to analyse the traffic on our site. For further information, including information on how to prevent or manage the use of cookies on this Platform, please refer to our Privacy and Cookie Policy.