I'm trying to set the position and orientation of a model via the primary part.
local ClonedObS = workspace.Model --Defined CFrames local PositionCFrame = CFrame.new(1,5,19) local OrientationCFrame = CFrame.fromEulerAnglesXYZ(math.rad(10), math.rad(1), math.rad(5)) ClonedObS:SetPrimaryPartCFrame(PositionCFrame, OrientationCFrame)) --This doesn't work for orientation
Is there a way I can set the position and orientation of a model in a CFrame?
ClonedObS:SetPrimaryPartCFrame(PositionCFrame) ClonedObS:SetPrimaryPartCFrame(OrientationCFrame) --Also doesn't work because it resets the previous CFrame ClonedObS:SetPrimaryPartCFrame(OrientationCFrame) ClonedObS:SetPrimaryPartCFrame(PositionCFrame) --Same...
You had it for the most part, you were just missing one little thing. We can add the orientation of a model just as if we are offsetting a CFrame.
For example, when you want to move something up by 5 studs you do:
part.CFrame = part.CFrame * CFrame.new(0, 5, 0)
Same goes for orientation, so what you will need to do is:
local ClonedObS = workspace.Model --Defined CFrames local PositionCFrame = CFrame.new(1,5,19) local OrientationCFrame = CFrame.fromEulerAnglesXYZ(math.rad(10), math.rad(1), math.rad(5)) local PosOrCFrame = PositionCFrame * OrientationCFrame --combining both ClonedObS:SetPrimaryPartCFrame(PosOrCFrame)
That should work.
Hope I helped. If you have any questions please let me know.