I have a chassis part that follows a target part. Currently, the chassis rotates freely when it is disturbed (player touching it, part falling on it, etc.). I would like the chassis to rotate only on the Y axis, like a 2D top down car. I do not want to directly set the CFrame of the part. Is there a BodyMover or constraint that can help me?
local RunService = game:GetService("RunService")
local Chassis = workspace.Chassis
local Target = workspace.Target
local BodyGyro = Chassis.BodyGyro
local BodyVelocity = Chassis.BodyVelocity
local Speed = 50
local DecelerationRange = 25
RunService.Stepped:Connect(function(Delta)
local TargetPosition = Vector3.new(Target.Position.X, 5, Target.Position.Z)
local CurrentPosition = Chassis.Position
local Difference = (TargetPosition - CurrentPosition)
local Distance = Difference.Magnitude
local Direction = Difference.Unit
local DecelerationFactor = math.min(1, Distance / DecelerationRange)
BodyGyro.CFrame = CFrame.new(CurrentPosition, TargetPosition)
BodyVelocity.Velocity = Direction * Speed * DecelerationFactor
end)