How to make AssemblyLinearVelocity sync with Tween movement?

Hello, scripters! I’m working on escalator script. I have noticed that it moves itself but it doesn’t move you. Is there anyway to sync AssemblyLinearVelocity with Tween movement perfectly using scripts?

Also how to sync AssemblyLinearVelocity with Tween movement if it has different EasingStyle?

I’m not sure there’s a reliable way to “sync” AssemblyLinearVelocity with a CFrame/Position tween. I’m not sure what sync would even mean in this case, but they’re different systems. The physics engine, in my understanding, should be independent from TweenService, so trying to align the player to it with physics doesn’t really make sense to me.

What I would suggest is something like this:

  • Player touches escalator
    • connect to RunService.Heartbeat
      • compare previous escalator part position to the current one
      • add the position difference to player’s root part

This should make sure the player stays on the escalator no matter where it moves, as every frame it will re-position the player to account for the change in position that the escalator faces.

Personally, your best bet would be to use AlignPosition and AlignOrientation, but if you want to stick with tweens, you can try to inspire yourself from this post:

Oh, and as a note, you can also use magnitude to see if the player is jumping or not. This can make the physic look more realistic.

If you need assistance to code such a thing, tell me!

1 Like

Looks like the same logic I suggested about adding the position difference, but also accounting for the rotation via the use of cframes. Neat.

Not clear what you’re actually suggesting here. If you’re talking about disabling the “add the difference” logic when you’re in mid-air, then yeah I agree. But I’m also not sure about which magnitude you’re talking about.

Also the post you referenced has some very, very old code. It can help with figuring out how to do this, but I wouldn’t copy the exact language it uses.

As always lol.

By Magnitude, I forgot to mention it’s like (A.Position - B.Position).Magnitude. But theorically, she can just watch if the Humanoid’s state is set to another state than Humanoid.State.Running or Humanoid.State.Running.

It’s why I said that she should inspire herself from that. Agree that the code hurt my eyes a bit, but the concept is still good.

1 Like

Hmmm… Okay thank you anyways
I only know how to sync AssemblyAngularVelocity with rotating part by tween:

local ts = game:GetService('TweenService')
local part = script.Parent
local AssemblyAngularVelocitySpeed = 2
local rad = 120/AssemblyAngularVelocitySpeed

while true do
   ts:Create(part,TweenInfo.new(math.rad(rad),Enum.EasingStyle.Linear),
       {CFrame = part.CFrame * CFrame.Angles(0,math.rad(120),0}):Play()
   task.wait(math.rad(rad))
end

There’s special formula: AssemblyAngularVelocitySpeed = 120/rad
Now I’m trying to figure out same with AssemblyLinearVelocitySpeed.
I’ll be experimenting with PrismaticConstraint to see.