How can I rewrite these codes to no longer use BodyGyros and BodyPositions? Been trying for a year

Greetings, I don’t know how to use AlignOrientations and LinearVelocities. I have these scripts with BodyGyros and BodyPositions, and enabling a recommended property Workspace.PhysicsSteppingMethod to Default or Adaptive breaks these cars. When the property gets removed, I am screwed.

I even tried using ChatGPT (Because I am that scared), but it doesn’t know that you can’t just replace the words in the code.

How can I rewrite these to use the new Constraints?

Server Script:

local Car = script.Parent
local Configuration = Car.Configurations
local Raycast = require(script.RaycastModule)

local Mass = 0
for _, v in ipairs(Car:GetChildren()) do
	if v:IsA("BasePart") then
		Mass += (v.Mass * 196.2)
	end
end

local Chassis = Car.Chassis
local BodyPosition = Chassis.BodyPosition
local BodyGyro = Chassis.BodyGyro

local function UpdateThruster(Thruster)
	local Blacklist = {}
	local Params = RaycastParams.new()
	Params.FilterType = Enum.RaycastFilterType.Blacklist
	Params.FilterDescendantsInstances = Blacklist

	local Result = workspace:Raycast(Thruster.Position, Thruster.CFrame:VectorToWorldSpace(Vector3.new(0, -1, 0)) * Configuration:GetAttribute("Height"), Params)
	local Hit, Position
	if Result then
		Hit = Result.Instance
		Position = Result.Position
	end
	if Hit and Hit:IsA("BasePart") and not Hit.CanCollide then
		table.insert(Blacklist, Hit)
	end
	if Position then
		local ThrusterHeight = (Position - Thruster.Position).Magnitude

		local WheelWeld = Thruster.WheelWeld
		WheelWeld.C0 = CFrame.new(0, -math.min(ThrusterHeight, Configuration:GetAttribute("Height") * 0.8) + (WheelWeld.Part1.Size.Y / 2), 0)
		local Offset = Chassis.CFrame:Inverse() * Thruster.CFrame
		local Speed = Chassis.CFrame:VectorToObjectSpace(Chassis.AssemblyLinearVelocity)
		if Offset.Z < 0 then
			local Direction = 1
			if Speed.Z > 0 then
				Direction = -1
			end
			WheelWeld.C0 *= CFrame.Angles(0, (Chassis.RotVelocity.Y / 2) * Direction, 0)
		end

		if Hit and Thruster.AssemblyLinearVelocity.Magnitude >= 5 then
			WheelWeld.Part1.ParticleEmitter.Enabled = true
		else
			WheelWeld.Part1.ParticleEmitter.Enabled = false
		end
	end
end

Car.DriveSeat:GetPropertyChangedSignal("Occupant"):Connect(function()
	if Car.DriveSeat.Occupant then
		if Configuration:GetAttribute("EngineSound") then
			Car.Chassis.Running:Play()
		end
		Car.Chassis.Running.PlaybackSpeed = 1
		local Player = game.Players:GetPlayerFromCharacter(Car.DriveSeat.Occupant.Parent)
		if Player then
			Car.DriveSeat:SetNetworkOwner(Player)
			local LocalCarScript = script.LocalCarScript:Clone()
			LocalCarScript.Parent = Player.PlayerGui
			LocalCarScript.Car.Value = Car
			LocalCarScript.Disabled = false
		end
	else
		Car.Chassis.Running:Stop()
	end
end)

Car.CoreStorage.ExitKart.OnServerEvent:Connect(function()
	local Humanoid = Car.DriveSeat.Occupant.Humanoid
	if Humanoid then
		Humanoid.Jump = true
	end
end)

while true do
	local start = tick()

	for _, Part in ipairs(Car.Thrusters:GetChildren()) do
		UpdateThruster(Part)
	end

	if Car.DriveSeat.Occupant then
		local Ratio = Car.DriveSeat.AssemblyLinearVelocity.Magnitude / Configuration:GetAttribute("Speed")
		Car.Chassis.Running.PlaybackSpeed = 1 + Ratio / 4
		BodyPosition.MaxForce = Vector3.new()
		BodyGyro.MaxTorque = Vector3.new()
	else
		local Blacklist = {}
		local Params = RaycastParams.new()
		Params.FilterType = Enum.RaycastFilterType.Blacklist
		Params.FilterDescendantsInstances = Blacklist
		local Result = game:GetService("Workspace"):Raycast(Car.Chassis.Position, Car.Chassis.CFrame:VectorToWorldSpace(Vector3.new(0, -1, 0)) * Configuration:GetAttribute("Height"), Params)
		local Hit, Position, Normal
		if Result then
			Hit = Result.Instance
			Position = Result.Position
			Normal = Result.Normal
		end
		if Hit and Hit.CanCollide then
			BodyPosition.MaxForce = Vector3.new(Mass / 5, math.huge, Mass / 5)
			BodyPosition.Position = (CFrame.new(Position, Position + Normal) * CFrame.new(0, 0, -Configuration:GetAttribute("Height") + 0.5)).Position
			BodyGyro.MaxTorque = Vector3.new(math.huge, 0, math.huge)
			BodyGyro.CFrame = CFrame.new(Position, Position + Normal) * CFrame.Angles(-math.pi/2, 0, 0)
		else
			BodyPosition.MaxForce = Vector3.new()
			BodyGyro.MaxTorque = Vector3.new()
		end
	end

	local elapsed = tick() - start
	if elapsed < 0.0167 then -- 60 FPS
		task.wait(0.0167 - elapsed)
	end
end

Local Script:

local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character.HumanoidRootPart
local Car = script:WaitForChild("Car").Value
local Configuration = Car:WaitForChild("Configurations")
local Raycast = require(Car.CarScript.RaycastModule)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ContextActionService = game:GetService("ContextActionService")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local PlayerGui = Player.PlayerGui

if UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled then
	if PlayerGui:FindFirstChild("TouchGui") then
		PlayerGui.TouchGui.Enabled = false
	end
end

local Movement = Vector2.new()

local MobileMovement = Car.MobileMovement:Clone()
MobileMovement.Parent = PlayerGui

local ForwardTweenInfo = TweenInfo.new(Car.Configurations:GetAttribute("FullSpeedTime"), Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false)
local TurnTweenInfo = TweenInfo.new(Car.Configurations:GetAttribute("FullSpeedTime"), Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false)

local VectorUp = Instance.new("NumberValue")
local VectorTurn = Instance.new("NumberValue")

VectorUp.Changed:Connect(function()
	Movement = Vector2.new(Movement.X, VectorUp.Value)
end)

VectorTurn.Changed:Connect(function()
	Movement = Vector2.new(VectorTurn.Value, Movement.Y)
end)

local ForwardTween
local BackwardTween

-- Forward Movement
local function Forward(InputName, InputState, InputObject)
	if InputState == Enum.UserInputState.Begin then
		if BackwardTween and BackwardTween:IsA("Tween") then
			BackwardTween:Cancel()
		end
		ForwardTween = TweenService:Create(VectorUp, ForwardTweenInfo, {Value = 1})
		ForwardTween:Play()
	else
		ForwardTween:Pause()
		VectorUp.Value = 0
	end
end

ContextActionService:BindActionAtPriority("Forward", Forward, false, 20000, Enum.KeyCode.W, Enum.KeyCode.Up, Enum.KeyCode.ButtonA)
MobileMovement.Forward.MouseButton1Down:Connect(function()
	Forward("Forward", Enum.UserInputState.Begin, Enum.KeyCode.W)
end)
MobileMovement.Forward.MouseButton1Up:Connect(function()
	Forward("Forward", Enum.UserInputState.End, Enum.KeyCode.W)
end)

-- Backward Movement
local function Backward(InputName, InputState, InputObject)
	if InputState == Enum.UserInputState.Begin then
		if ForwardTween and ForwardTween:IsA("Tween") then
			ForwardTween:Cancel()
		end
		BackwardTween = TweenService:Create(VectorUp, ForwardTweenInfo, {Value = -0.5})
		BackwardTween:Play()
	else
		BackwardTween:Pause()
		VectorUp.Value = 0
	end
end

ContextActionService:BindActionAtPriority("Backward", Backward, false, 20000, Enum.KeyCode.S, Enum.KeyCode.Down, Enum.KeyCode.ButtonB)
MobileMovement.Backward.MouseButton1Down:Connect(function()
	Backward("Forward", Enum.UserInputState.Begin, Enum.KeyCode.S)
end)
MobileMovement.Backward.MouseButton1Up:Connect(function()
	Backward("Forward", Enum.UserInputState.End, Enum.KeyCode.S)
end)

-- Left Movement
local function Left(InputName, InputState, InputObject)
	if InputState == Enum.UserInputState.Begin then
		Movement = Vector2.new(-1, Movement.Y)
	else
		Movement = Vector2.new(0, Movement.Y)
	end
end

ContextActionService:BindActionAtPriority("Left", Left, false, 20000, Enum.KeyCode.A, Enum.KeyCode.Left)
MobileMovement.Left.MouseButton1Down:Connect(function()
	Left("Left", Enum.UserInputState.Begin, Enum.KeyCode.A)
end)
MobileMovement.Left.MouseButton1Up:Connect(function()
	Left("Left", Enum.UserInputState.End, Enum.KeyCode.A)
end)

-- Right Movement
local function Right(InputName, InputState, InputObject)
	if InputState == Enum.UserInputState.Begin then
		Movement = Vector2.new(1, Movement.Y)
	else
		Movement = Vector2.new(0, Movement.Y)
	end
end

ContextActionService:BindActionAtPriority("Right", Right, false, 20000, Enum.KeyCode.D, Enum.KeyCode.Right)
MobileMovement.Right.MouseButton1Down:Connect(function()
	Right("Right", Enum.UserInputState.Begin, Enum.KeyCode.D)
end)
MobileMovement.Right.MouseButton1Up:Connect(function()
	Right("Right", Enum.UserInputState.End, Enum.KeyCode.D)
end)

-- Xbox Support
UserInputService.InputChanged:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.Thumbstick1 then
		if Input.Position.X ~= 0 and Input.Position.X < 0 then
			Left("Left", Enum.UserInputState.Begin, Enum.KeyCode.Thumbstick1)
		elseif Input.Position.X ~= 0 and Input.Position.X	> 0 then
			Right("Right", Enum.UserInputState.Begin, Enum.KeyCode.Thumbstick1)
		elseif Input.Position.X == 0 then
			Right("Right", Enum.UserInputState.End, Enum.KeyCode.Thumbstick1)
			Left("Left", Enum.UserInputState.End, Enum.KeyCode.Thumbstick1)
		end
	end
end)


--if not Configuration:GetAttribute("AllowedToExit") then
--	MobileMovement.Exit.Visible = false
--end

local function ExitKart()
	Car.CoreStorage.ExitKart:FireServer()
	MobileMovement:Destroy()
	ContextActionService:UnbindAction("Forward")
	ContextActionService:UnbindAction("Backward")
	ContextActionService:UnbindAction("Left")
	ContextActionService:UnbindAction("Right")
end

--MobileMovement.Exit.Activated:Connect(ExitKart)

-- Core Movement

local Force = 0
local Damping = 0

local Mass = 0

for i, v in Car:GetChildren() do
	if v:IsA("BasePart") then
		Mass = Mass + (v.Mass * 196.2)
	end
end

Force = Mass * Configuration:GetAttribute("Suspension")
Damping = Force / Configuration:GetAttribute("Bounce")

local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Velocity = Vector3.new(0, 0, 0)
BodyVelocity.MaxForce = Vector3.new(0, 0, 0)
BodyVelocity.Parent = Car.Chassis

local BodyAngularVelocity = Instance.new("BodyAngularVelocity")
BodyAngularVelocity.AngularVelocity = Vector3.new(0, 0, 0)
BodyAngularVelocity.MaxTorque = Vector3.new(0, 0, 0)
BodyAngularVelocity.Parent = Car.Chassis

local Rotation = 0

local function UpdateThruster(Thruster)
	local Blacklist = {}
	
	local BodyThrust = Thruster:FindFirstChild("BodyThrust")
	if not BodyThrust then
		BodyThrust = Instance.new("BodyThrust")
		BodyThrust.Parent = Thruster
	end
	
	local Params = RaycastParams.new()
	Params.FilterType = Enum.RaycastFilterType.Blacklist
	Params.FilterDescendantsInstances = Blacklist
	
	--local Result = game:GetService("Workspace"):Raycast()
	
	
	local Hit, Position = Raycast.new(Thruster.Position, Thruster.CFrame:VectorToWorldSpace(Vector3.new(0, -1, 0)) * Configuration:GetAttribute("Height"))
	local ThrusterHeight = (Position - Thruster.Position).Magnitude
	if Hit and Hit.CanCollide then
		BodyThrust.Force = Vector3.new(0, ((Configuration:GetAttribute("Height") - ThrusterHeight)^2) * (Force / Configuration:GetAttribute("Height") ^ 2), 0)
		local ThrusterDamping = Thruster.CFrame:ToObjectSpace(CFrame.new(Thruster.Velocity + Thruster.Position)).Position * Damping
		BodyThrust.Force = BodyThrust.Force - Vector3.new(0, ThrusterDamping.Y, 0)
	else
		BodyThrust.Force = Vector3.new(0, 0, 0)
	end

	local WheelWeld = Thruster:FindFirstChild("WheelWeld")
	if WheelWeld then
		WheelWeld.C0 = CFrame.new(0, -math.min(ThrusterHeight, Configuration:GetAttribute("Height") * 0.8) + (WheelWeld.Part1.Size.Y / 2), 0)
		local Offset = Car.Chassis.CFrame:Inverse() * Thruster.CFrame
		local Speed = Car.Chassis.CFrame:VectorToObjectSpace(Car.Chassis.Velocity)
		if Offset.Z < 0 then
			local Direction = 1
			if Speed.Z > 0 then
				Direction = -1
			end
			WheelWeld.C0 = WheelWeld.C0 * CFrame.Angles(0, (Car.Chassis.RotVelocity.Y / 2) * Direction, 0)
		end
		WheelWeld.C0 = WheelWeld.C0 * CFrame.Angles(Rotation, 0, 0)
	end
end

local function IsGrounded()
	local Blacklist = {}
	local Params = RaycastParams.new()
	Params.FilterType = Enum.RaycastFilterType.Blacklist
	Params.FilterDescendantsInstances = Blacklist
	local Result = game:GetService("Workspace"):Raycast((Car.Chassis.CFrame * CFrame.new(0, 0, (Car.Chassis.Size.Z / 2) - 1)).p, Car.Chassis.CFrame:VectorToWorldSpace(Vector3.new(0, -1, 0)) * (Configuration:GetAttribute("Height") + 0.2))
	if Result then
		local Hit, Position = Result.Instance, Result.Position
		if Hit and Hit.CanCollide then
			return true
		end
		return false
	else
		return false
	end
end

while game:GetService("RunService").Heartbeat:Wait() and Car:FindFirstChild("DriveSeat") and Character.Humanoid.SeatPart == Car.DriveSeat do
	if IsGrounded() then
		if Movement.Y ~= 0 then
			local Velocity = HumanoidRootPart.CFrame.LookVector * Movement.Y * Configuration:GetAttribute("Speed")
			HumanoidRootPart.AssemblyLinearVelocity = HumanoidRootPart.AssemblyLinearVelocity:Lerp(Velocity, 0.1)
			BodyVelocity.MaxForce = Vector3.new(0, 0, 0)
		else
			BodyVelocity.MaxForce = Vector3.new(Mass / 2, Mass / 4, Mass / 2)
		end
		local RotVelocity = HumanoidRootPart.CFrame:VectorToWorldSpace(Vector3.new(Movement.Y * Configuration:GetAttribute("Speed") / 50, 0, -HumanoidRootPart.RotVelocity.Y * 5 * Movement.Y))
		local Speed = -HumanoidRootPart.CFrame:VectorToObjectSpace(HumanoidRootPart.AssemblyLinearVelocity).unit.Z
		Rotation = Rotation + math.rad((-Configuration:GetAttribute("Speed") / 5) * Movement.Y)
		if math.abs(Speed) > 0.1 then
			RotVelocity = RotVelocity + HumanoidRootPart.CFrame:VectorToWorldSpace((Vector3.new(0, -Movement.X * Speed * Configuration:GetAttribute("TurnSpeed"), 0)))
			BodyAngularVelocity.MaxTorque = Vector3.new(0, 0, 0)
		else
			BodyAngularVelocity.MaxTorque = Vector3.new(Mass / 4, Mass / 2, Mass / 4)
		end
		HumanoidRootPart.RotVelocity = HumanoidRootPart.RotVelocity:Lerp(RotVelocity, 0.1)
	else
		BodyVelocity.MaxForce = Vector3.new(0, 0, 0)
		BodyAngularVelocity.MaxTorque = Vector3.new(0, 0, 0)
	end

	for _, Part in Car.Thrusters:GetChildren() do
		UpdateThruster(Part)
	end
end
for _, Parts in Car:GetChildren() do
	if Parts:FindFirstChild("BodyThrust") then
		Parts.BodyThrust:Destroy()
	end
end
BodyVelocity:Destroy()
BodyAngularVelocity:Destroy()
if UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled then
	if PlayerGui:FindFirstChild("TouchGui") then
		PlayerGui.TouchGui.Enabled = true
	end
end
script:Destroy()
ExitKart()

Thanks in advance!