I have a rotating cube and I want to have some moving parts on the cube that also rotate with the cube. Currently, to achieve this, I am using a for loop with lerp. The start and end parts are attached to the cube so they rotate with the cube.
local MovingPart = script.Parent
local Start = MovingPart.Parent.Start
local End = MovingPart.Parent.End
--parts are in a model
while true do
for i = 0, 1, 0.005 do
wait()
MovingPart.CFrame = MovingPart.CFrame:Lerp(End.CFrame, i)
end
for x = 0, 1, 0.005 do
wait()
MovingPart.CFrame = MovingPart.CFrame:Lerp(Start.CFrame, x)
end
wait()
end
This does move the part between the two points and it rotates with the cube but it doesn’t move in a straight line, which is what I would like, when the cube rotates too quickly.
I’ve tried using Prismatic Constraints so the part only moves on the line but when I unanchor the moving part for the constraint to work, the moving part shakes uncontrollably.
I’ve also tried using BodyMovers and it didn’t work (probably because of my lack of knowledge on them so I am still open to trying them out).
I’m out of ideas so if you have any suggestions or any other method of doing this I’d like to hear them.