So I have never made a car before and I’m having issues trying to script the car so that it won’t go over a certain speed, but rather maintain a speed that’s at the speed limit. My car relies on a bodyforce to accelerate / deaccelerate itself. Here is the script if you need it:
local Acceleration = Instance.new('BodyForce')
Acceleration.Force = Vector3.new(0,0,0)
Acceleration.Parent = script.Parent
local MaxSpeed = 40
script.Parent:GetPropertyChangedSignal('Throttle'):Connect(function()
if script.Parent.Throttle == 1 then
if script.Parent.AssemblyLinearVelocity.Magnitude >= MaxSpeed then
Acceleration.Force = Vector3.new(0,0,0)
else
Acceleration.Force = script.Parent.CFrame.LookVector * 50000
end
elseif script.Parent.Throttle == 0 then
Acceleration.Force = Vector3.new(0,0,0)
else
if script.Parent.AssemblyLinearVelocity.Magnitude >= MaxSpeed then
Acceleration.Force = Vector3.new(0,0,0)
else
Acceleration.Force = script.Parent.CFrame.LookVector * -50000
end
end
end)