Help with CFrames

Hello. I’m stupid bad with CFrames and math in general so I apologise for the question. How would I get the CFrames of points A and B from the CFrame of the part in the Image I have attached?

I’ve tried subtracting and adding half the size of the part to it’s CFrame to get A and B respectively but they don’t seem to change when I’ve tried rotating the part.

I would appreciate any help. Thanks.


You can do this with some simple CFrame math:

Part.CFrame = Part.CFrame *, 0, 0)
You can play around with that code to see what you will get.
You should only change the “Part.Size.X/2” either by dividing by less or by adding a minus to it.

Part.CFrame = Part.CFrame *, 0, 0) * CFrame.Angles(0, math.rad(25), 0)
The code above will rotate the part 25 degrees in the end of the part.

I hope this helped! Please message me if you have any questions!

1 Like

I think I should have worded this better.

Here is a visual of what is happenning:

The two parts at the end of the part are not following the ends of the centre part when rotate it. They seems to only rotate.

Here is the code I wrote to experiment:

while true do
    local Part = script.Parent
    local p1 ="Part",workspace)
    local p2 ="Part",workspace)
    local leftwardBoundCFrame = Part.CFrame -, 0, Part.Size.Z/2)
    local rightwardBoundCFrame = Part.CFrame +, 0, Part.Size.Z/2)
    p1.CFrame = leftwardBoundCFrame
    p2.CFrame = rightwardBoundCFrame
    p1.Anchored = true
    p2.Anchored = true

Make sure you learn about Object and World space.
Object space is relative to the CFrame
World space is relative to to the origin

part.CFrame *,0,Z/2) (a:ToWorldSpace(b)) for example will be a local transformation because it assumes <0,0,Z/2> is local to part.CFrame, converting it into world space (transforming part.CFrame)
part.CFrame +,0,Z/2) is a global transformation

1 Like