Need help with rotation

I am trying to create a new object from replicated storage which will be known as “Model” in the script and rotate it off of the model before it. I am trying to make an infinite obby sort of thing with turns and straights.

Script:
model:SetPrimaryPartCFrame(model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(model.PrimaryPart.Orientation.Y + 90), 0))

The y rotation usually comes out as 116 rather than a multiple of 90 like I wanted. I tried printing the y rotation value but it just came back as zero and I think that is my problem.

I want to figure this out so that I can move onto developing another part of my game.

The problem is probably that multiplying CFrames together is a relative operation—the result is based on the current orientation.

In other words you probably just want to do this:

model:SetPrimaryPartCFrame(model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(90), 0))
1 Like