c.CFrame = Player.Character.Torso.CFrame.new(0, -2, 0)*CFrame.new(0, -math.pi/4, 0)
The code should rotate 1/4 of a turn but it doesnt.
It's very difficult to identity what transformation you are trying to apply, neoG457, but my guess is that you want to take the CFrame
of the character's Torso
, translate it by (0, -2, 0) and rotate by 90 degrees around the y-axis.
To translate a CFrame
by a vector value you can either add or subtract a Vector3
value or multiply by another CFrame
.
For example, if I want to move a CFrame
called 'aCFrame' by (0,-2,0) I could either do:
aCFrame = aCFrame * CFrame.new(0,-2,0)
or:
aCFrame = aCFrame + Vector3.new(0,-2,0)
or:
aCFrame = aCFrame - Vector3.new(0,2,0)
To rotate a CFrame
, we specify an angle to rotate by for each of the three axes: x (pitch), y (yaw), z (roll).
Angles are specified in radians, where pi radians is equal to 90 degrees. You can either give your rotation as a multiple of pi (Today is pi day, by the way), or you can use the math.rad
function to change degrees into radians.
So, if you want to rotate around the y-axis (yaw) by 90 degrees, you could either:
aCFrame = aCFrame * CFrame.Angles(0, math.pi/2, 0)
or:
aCFrame = aCFrame * CFrame.Angles(0, math.rad(90), 0)
You can compute a CFrame
that is a translated, rotated version of a character's Torso by combining the above:
c.CFrame = Player.Character.Torso.CFrame * CFrame.new(0, -2, 0) * CFrame.Angles(0, math.pi/2, 0)
You can read more about CFrame
on the Official ROBLOX Wiki.
Instead of using:
c.CFrame = Player.Character.Torso.CFrame.new(0, -2, 0)*CFrame.new(0, -math.pi/4, 0)--Notice the 2nd CFrame.new
You can change the CFrames Angles. You must use math.rad on this (math.radians), in order to change the rotation of the object.
c.CFrame = CFrame.new(0, -2, 0)*CFrame.Angles(0, math.rad(-math.pi/4), 0)
You can also do this with cameras.
This was really simple. Hope this helps!
Using
c.CFrame = Player.Character.Torso.CFrame.new
is incorrect because you can't create a new CFrame when one is already present. Try using
c.CFrame = CFrame.new(0, -2, 0) -- Change the position you want to teleport the player to *CFrame.new(0, -math.pi/4, 0)