First of all I’d like to say sorry because I already asked this a few days ago but I just realised that the solution I found was wrong. My problem is that I want to rotate a model 180 degrees on the y axis with cframe, while it has multiple parts welded inside the primary Part. My problem occurs when the part has already been rotated on another axis because then my part not only flips on the y value but on the other axis too. How would I make it so only the y axis changes
1 Like
This is the code you can use to rotate a cframe locally on the y axis by 180 degrees
local newCF = oldcf * CFrame.Angles(0, math.rad(180), 0)
This means that an object would turn around to face behind it.
If this is not giving you the results you expect, you may either want to rotate it on a different axis, or you may want to rotate it on the global y-axis. The code is a bit different for rotating on the global axis though.
Edit: I used math.deg() when I meant to use math.rad()
1 Like
I want to rotate it on the global axis
local newCF = CFrame.new(oldCF.Position) * CFrame.Angles(0,math.rad(180),0) * oldCF.Rotation
3 Likes
Thank you so much, I have been looking for this for the past 45 minutes!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.