Hello, what I’m trying to achieve is to replicate what a weld does with parts orientations, so let’s say I move the main part and rotate it, I want the script to rotate the parts in the same way the main part rotated, can you help me?
1 Like
Something like?:
local Part1 ---- part you want the rotation from
local Part2 --- part you want rotate
local Rotation = ( Part1.CFrame - Part1.Position) --remove position
Part2.CFrame = Rotation + Part2.Position ---- add back position with part 2's position
3 Likes
When working with CFrame you have to use * instead of +
1 Like
Are you sure? i’m pretty sure you can add CFrames
2 Likes
I’m doing a sort of draw of what I mean.
1 Like
When doing CFrame * is the equivalent to using +
1 Like
local Part1
local Part2
local rotation = Part1.CFrame:inverse() * Part2.CFrame
Part1.CFrame = Part1.CFrame * CFrame.Angles(0,math.rad(90), 0)
Part2.CFrame = Part1.CFrame * rotation
2 Likes
Actually your code is correct since you aren’t transferring the Vector3 into a CFrame. Sorry for the confusion.
2 Likes