Can you try this script instead of your current one? VehicleSeat2Module
-- MADE BY NWSPACEK
local Vehicle = script.Parent.Parent
local Configuration = Vehicle:WaitForChild("VehicleSeat2 Configuration")
local Seat = Configuration:WaitForChild("DriverSeat").Value
local AccelerationValue = Configuration:FindFirstChild("Acceleration")
local Acceleration = AccelerationValue and AccelerationValue.Value or 0
if AccelerationValue then
AccelerationValue:GetPropertyChangedSignal("Value"):Connect(function() Acceleration = AccelerationValue.Value end)
end
local DoMakeJoints = Configuration:FindFirstChild("MakeJoints") and Configuration.MakeJoints.Value or not Configuration:FindFirstChild("MakeJoints")
local module = {}
local Run = false
local UpdateConnection
local RS = game:GetService("RunService")
local MotorHinges = {}
type MotorHinge = {
Constraint: HingeConstraint,
Radius: Number,
Distance: Number,
Direction: Number
}
local ConstraintFunctionMap = require(script.Parent:WaitForChild("ConstraintFunctions"))
if RS:IsServer() then -- the server's job is to make the constraints
local function MakeHinge(attachment1,ph) -- this function creates a hinge and puts it in MotorHinges
--if not ph then warn("Could not find parent handle part for",attachment1:GetFullName()) return end
if ConstraintFunctionMap[attachment1.Name] then
ConstraintFunctionMap[attachment1.Name](attachment1,ph)
end
end
local function welding(p,ph) -- use a recursive function to limit scope to a direct hierarchy
local handle = p:FindFirstChild("AHandle")
if not handle then
handle = ph
end
for _,j in pairs (p:GetChildren()) do
if j:IsA("BasePart") then
for _,k in ipairs (j:GetChildren()) do
if k:IsA("Attachment") then
MakeHinge(k,ph)
end
end
elseif j:IsA("Model") then
welding(j,handle)
end
end
end
if DoMakeJoints then
welding(script.Parent.Parent)
end
end
-- I realize I could put this in the server part of the script, but I leave it out here so the server can grab any pre-configured motors
for _,Constraint in ipairs (Vehicle:GetDescendants()) do
if Constraint:IsA("HingeConstraint") and Constraint.Name == "VS2Motor" then
local Motor
local Properties = Constraint:FindFirstChild("MotorProperties")
if Properties then
Motor = {
Constraint = Constraint,
Radius = Properties.Value.Z ~= 0 and Properties.Value.Z or 1,
HDistance = Properties.Value.Y,
Direction = Properties.Value.X,
}
else
Motor = {
Constraint = Constraint,
Radius = math.max(0.05, Constraint.Attachment1.Parent.Size.Z * 0.5),
HDistance = Constraint.Attachment0.Position.X,
Direction = math.sign(Constraint.Attachment0.Axis:Dot(Vector3.new(-1, 0, 0))),
}
end
table.insert(MotorHinges, Motor)
end
end
local function Update()
-- TurnSpeed: radians/s of the vehicle
-- MaxSpeed: studs/s of the vehicle
-- Acceleration: studs/s^2 of the vehicle
local TargetSpeed = Seat.ThrottleFloat * Seat.MaxSpeed
local TargetTurn = -Seat.SteerFloat * Seat.TurnSpeed -- negative due to right-hand rule
local TargetAcceleration = Acceleration == 0 and math.huge or Acceleration
-- Dynamically increase torque and acceleration during turns
local TurnFactor = 1 + math.abs(Seat.SteerFloat) * 0.5 -- Adjusts torque and acceleration based on the amount of steering
for _,C in ipairs (MotorHinges) do
-- Dynamically increase torque when steering to handle resistance during turns
C.Constraint.MotorMaxTorque = Seat.Torque * TurnFactor
-- Adjust MotorMaxAcceleration based on steering input
C.Constraint.MotorMaxAcceleration = (TargetAcceleration * TurnFactor) / C.Radius
if TargetSpeed < 0 then
C.Constraint.AngularVelocity = (TargetSpeed - TargetTurn * C.HDistance) * C.Direction / C.Radius
else
C.Constraint.AngularVelocity = (TargetSpeed + TargetTurn * C.HDistance) * C.Direction / C.Radius
end
end
end
function module.StartSimulation()
Run = true
if RS:IsClient() then
UpdateConnection = RS.Stepped:connect(Update) -- Why do I use stepped here?
-- Roblox's physics pipeline makes Stepped the obvious choice for this kind of system, where the client and server are both
-- computing for the same vehicle. The Stepped event comes before physics calculations, but after replication, so in can not
-- only use the most up-to-date data on both client and server, but it will also ignore the server's data in favor of the client's.
-- A graph showing the update phases of Roblox: https://devforum.roblox.com/t/runservice-heartbeat-switching-to-variable-frequency/23509/7
else
while Run do
wait()
Update()
end
end
end
function module.EndSimulation()
Run = false
if UpdateConnection then
UpdateConnection:disconnect()
UpdateConnection = nil
end
end
return module
Now the wheels smoothly adjust the speed using HDistance (Horizontal Distance) to ensure that each wheel rotates correctly during turns, and then a new variable TurnFactor which will adjust the acceleration based on the degree of steering, and also increased the torque proportionally to how much the player is steering