Codectionary / Developer documentation / Luau

LinearVelocity

Drive an assembly toward a target velocity.

Why use LinearVelocity?

LinearVelocity is a constraint that attempts to maintain linear motion. It is useful for moving platforms or conveyor-like objects when a velocity target is clearer than a raw force.

Try it in Roblox Studio

Create an unanchored Part named Mover in Workspace and run this Script from ServerScriptService. Keep its path clear for testing.

Syntax

velocity.VectorVelocity = Vector3.new(8, 0, 0)

Examples

LinearVelocity

Move a part along the world X axis.

local mover = workspace:WaitForChild("Mover")
assert(mover:IsA("BasePart"))
local attachment = Instance.new("Attachment")
attachment.Parent = mover

local velocity = Instance.new("LinearVelocity")
velocity.Attachment0 = attachment
velocity.RelativeTo = Enum.ActuatorRelativeTo.World
velocity.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector
velocity.VectorVelocity = Vector3.new(8, 0, 0)
velocity.MaxForce = 10000
velocity.Parent = mover
  1. The attachment connects the constraint to the moving assembly.
  2. Vector mode and VectorVelocity define a desired world-space speed and direction.
  3. MaxForce limits the effort available to reach that speed; collisions, mass, and anchoring can change the observed motion.

Best practices

  • Use an unanchored assembly for physics-driven movement.
  • Tune MaxForce for the assembly instead of setting arbitrarily enormous values.

Runtime & versions

Luau host; Roblox engine examples require Roblox Studio. Feature availability depends on the language and runtime version used by your project; consult the official reference below.

Luau documentation

Specifications & further reading