How to move bricks using CFrame?

I’m wondering how to move parts using CFrame. I am aware on how to move them directly to the position.

part.CFrame = CFrame.new(x, y, z)

My question is how do you make them with motion so you can clearly see them move instead of jumping to a position?

Thanks,
Bylocks

You have two options. The first one is tween them by moving them a lil-bit multiple times a second. The second would be to unanchor the part and add a bodyposition to it that you change. There might be more ways to do this but those are the only ones I can think of.

TweenService is a great way to go.

Except in some special cases of animating things client-side, you generally don’t want to animate parts by setting the CFrame. When done server side, everyone will see this animation happening at the replication rate, which is significantly lower than render framerate, so it will look choppy. Anchored parts animating by CFraming also ignore physics, and can pass right through other parts.

When you want to animate something smoothly, and the position has to be consistent for all players (i.e. they all see the thing animating the same way), you really want to use a non-CFrame method like the body movers, constraints, motors, etc. The client knows how to interpolate between updates for things that are physically simulated, so they appear to animate smoothly, just like player characters and animations do.

That said, if you are animating something on the client–for which there are valid use cases–you can use TweenService, or just manually calculated interpolation. For the latter, I prefer using timestamps (e.g. a tick() - t0 approach) rather than the time delta passed to Heartbeat or Renderstep, to avoid accumulating error.

3 Likes