Hmm, maybe let’s try the earlier Attachment axis approach to achieve the desired rotation, to do this we construct the axis to get the right vector and up vector of the floor:
This piece of code will change the floor CFrame according to how the attachments axis is set.
This uses CFrame from matrix which can be explained in this thread
--Put floor at attachment position via CFrame
local floorCframe = floor.CFrame *CFrame.new(ClosestAttachment.Position)
--Achieve goal rotation CFrame using axis from attachments
--We put emptyVector because we don't want to add position into the CFrame from matrix
--Only rotation using the upvector and right vector
local emptyVector = Vector3.new(0,0,0)
local attachmentWorldUpvector = ClosestAttachment.WorldSecondaryAxis
local attachmentWorldRightvector = ClosestAttachment.WorldAxis
local goalRotationCFrame = CFrame.fromMatrix(emptyVector,attachmentWorldRightvector,attachmentWorldUpvector)
--apply rotation to floor rotation
floorCframe = floorCframe * goalRotationCFrame
--Then offset the position of the floor CFrame
floorCframe = floorCframe *CFrame.new(-floor.FloorAttachment.Position)