I tried using something like CFrame.new(BlueBrickPos.X, TopCirclePos.Y, BlueBrickPos.Z), but the problem is that if the wall changes to other random orientation, the circles end up floating because they are not relative to the blue brick.
I’m terrible with anything related to math with CFrame no exception.
However, after a few attempts, I managed to make this attachment relative to the part (it’s placed in workspace.Terrain and WorldCFrame).
This is the code:
local part = script.Parent
local attachment = Instance.new("Attachment")
attachment.Visible = true
attachment.CFrame = CFrame.new()
attachment.Position = Vector3.zero
attachment.Parent = workspace.Terrain
while true do
attachment.WorldPosition = part.CFrame:PointToWorldSpace(Vector3.yAxis*0.5+Vector3.xAxis*-0.1)
task.wait()
end
As I expected, the solution was very simple. I made a variable of the difference between the CFrames and added the difference in CFrames to the BlueBrickCFrame, but without passing the X variable, and that was it, lol.
local UpDiference:CFrame = PartCF:Inverse() * UpBoundingCFrame
local UpCFrame = PartCF * CFrame.new(0, UpDiference.Position.Y, UpDiference.Position.Z) * CFrame.Angles(UpDiference:ToOrientation())
SphereOrWhatever.CFrame = UpCFrame