Why rotation isn't being loaded properly?

My mailboxs position is being saved correctly, but when loading it back in, the rotation doesn’t take into account the plots rotation as well

local Position = PlayersExterior.PrimaryPart.CFrame * Vector3.new(Mailbox[1].Value, Mailbox[2].Value, Mailbox[3].Value)

local LookVector = Vector3.new(Mailbox[4].Value, Mailbox[5].Value, Mailbox[6].Value)
				
PlayersExterior.Build.Mailbox:SetPrimaryPartCFrame(CFrame.new(Position, Position + (LookVector * 5)))

Default position, so when you first play this is how the mailbox default loads


Now I want to in the future add a way to move your mailbox, but I haven’t added that yet. The mailbox however still loads incorrectly from your saved data

Can see ‘5’ is the Y axis of the rotation. When you first played, it was 0, so it’s been saved as 0. When you reload, the mailbox stays at 0. It should rotate based on the plots rotation tho (as you get a different spot each time)

Just gonna bump this

1 Like

This is probably happening because you aren’t applying the rotation relative to the base of the plot and instead pulling and using raw position data. Naturally that would place the mailbox in global space, so it ignores the orientation of the plot.

Not an issue of improperly saved data. This code is doing exactly what you’ve programmed it to do.

I meant loading properly. And if I am doing that (which I knew I was doing, because why else would it be doing this) then it would have been nice to know how to fix it because I have virtually no clue why it ain’t working.

Bare in mind, this code was written years ago by someone else.

CFrame.new(Position, Position + (LookVector * 5))

Makes no sense to me, but it worked in the past :man_shrugging: