How do I make this go faster?

VIDEO AT BOTTOM OF POST

  • What are you attempting to achieve? I want the cart to go as fast as possible and not slow down on corners (It’s funnier and makes the game difficult)
  • What is the issue? It keeps going 30-40 studs per second on corners when I want it to be going 80-100
  • What solutions have you tried so far? (Have you searched for solutions through the Roblox Wiki yet?) None.

It would also be helpful on how to make it go fast when going on loops like the photo below

Watch the speed from where I am on a straight track to when I am on a corner/going up

4 Likes

This all depends on what propulsion the cart uses.

1 Like

What do you mean? It uses VehicleSeat2 to move. I just disabled A and D turning.

1 Like

What propulsion force do you use for movement?

1 Like

I don’t know what you mean by that.

1 Like

Acceleration is set to 50 under the config if that is what you mean

1 Like

jumping on the conversation

try boosting it to 60, and see if it’ll make a difference.

haven’t tested it, so try it out, and record the outcome

Didn’t change anything. Went round a corner at 80sps and came out of it at 35sps.

boost it to 90-100, maybe?

post limits extension ig idk

Again didn’t change much, Came into curve at 100sps and came out at 31sps.

Can you possibly provide the script/s?

This is the cart file, Has all of the VS2 components inside.
(file deleted)

Thank you, I’ll take a look and get back to you!

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

1 Like

Afaik there has to be some force applied to the vehicle assembly to move it.

Unless the VehicleSeat automatically does that?

What you can try is editing the VehicleSeat’s properties while playing. This way you can instantly test the changes.

Yeah sure, I’ll give it a test.

Works a bit better, Went much faster around bends than before but still struggle to go up slopes.

Try to increase the torque even more, and make sure to keep the limiters off

Where are limiters? I turned the torque up a lot and it is nice and smooth now.

I already turned off the limiters and they aren’t in the script I provided, and I’m glad it’s working well now