So whenever I teleport the model, It turns to the right. I don't want that happening. So how do I Set a Primary Part Orientation? Here's the code:
--Variables local Echo = script.Parent --Positions wait(10) script.Parent:SetPrimaryPartCFrame()(Vector3.new(1.67, 3.054, 44.89)) Echo.Shutter:Play() wait(10) script.Parent:SetPrimaryPartCFrame(CFrame.new(3.966, 3.054, 44.89)) Echo.Shutter:Play()
Any ideas?
There are a few things wrong. First, SetPrimaryPartCFrame()
doesn't work like that. It works like this: model:SetPrimaryPartCFrame(CFrame.new())
. It has to go inside the parentheses. Second, CFrame.new()
accepts 2 main Vector3s: Position and LookVector.
An example: Lets say you want to move Part1 to Part2 and have it face Part3:
Part1.CFrame = CFrame.new(Part2.Position, Part3.Position); -- it will teleport to Part2's position but face towards Part3's position.
Another example: Part1 teleports to origin and faces directly up.
Part1.CFrame = CFrame.new(Vector3.new(0, 0, 0), Vector3.new(0, 10, 0));
Now, you can also multiply a CFrame by CFrame.Angles(radX, radY, radZ) to rotate it. Keep in mind that CFrame.Angles() accepts radians only, so you can convert between degrees to radians VIA math.rad(degree).
For example, lets say we want to teleport Part1 to Part2 and rotate it 90 degrees. You can do this 2 ways:
Part1.CFrame = Part2.CFrame * CFrame.Angles(0, math.pi/2, 0); -- Rotate it 90 degrees on the Y axis
or
Part1.CFrame = Part2.CFrame * CFrame.Angles(0, math.rad(90), 0); -- same thing but using math.rad
Here are some resources to help you get started: