Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how do I replace the Vector3 in a CFrame?

hello, I'm trying to "transfer" the Orientation of a CFrame to another position:

local oldCF = CFrame.new(cam.CFrame.Position,hrp.Position)
local oldCFAngles = oldCF - oldCF.Position
local newcframe = hrp.Position + oldCFAngles

the math doesn't seem to work, I'm not sure on how to go about this. I'm subtracting the position from a cframe and that should leave me with just the orientation right? so all I need to do to construct a new cframe is to add another position?

1 comment

0

Instructions Unclear

1 answer

I think you just messed the order. It seems like when you want to operate CFrame with Vectors you have to start with the CFrame Value, but on line 3 you started with a vector and then added a CFrame. Maybe changing the order there will fix it.

newCFrame = oldCFrame-OldPosition+newPosition (I tested and it worked)

Not Sure if that's the best way though.

This discussion is preserved as it was. New answers, comments, and votes are closed.