I’m trying to create a boost/NOS system using BodyVelocity, but the problem is that it doesn’t work in all directions, particularly where the player is driving. It only propels the vehicle forward, and when I turn or drive in the backward direction, it slows down. Additionally, it doesn’t function properly when turning right or left.
local isBoosting = false
local model = script.BodyValue.Value
local exhaust = model.Body:WaitForChild("Boost").Trail0
local boostTorque = 50
local bodyVelocity = Instance.new("BodyVelocity", script.Parent)
bodyVelocity.MaxForce = Vector3.new(0,0,0)
bodyVelocity.Velocity = Vector3.new(0,0,0)
function Boost()
if not isBoosting and script.Parent.Occupant then
isBoosting = true
local player = script.Parent.Occupant.Parent
local boostDirection = player.HumanoidRootPart.CFrame.LookVector
bodyVelocity.MaxForce = boostDirection * boostTorque
for _, v in pairs(exhaust:GetChildren()) do
if v:IsA("Trail") then
v.Enabled = true
end
end
wait(4)
for _, v in pairs(exhaust:GetChildren()) do
if v:IsA("Trail") then
v.Enabled = false
end
end
bodyVelocity.MaxForce = Vector3.new(0, 0, 0)
isBoosting = false
end
end
game.ReplicatedStorage:WaitForChild("Boost").OnServerEvent:Connect(Boost)
Because you need to update the lookvector on a loop, such as
while bodyVelocity ~= nil do
if player:FindFirstChild("HumanoidRootPart") ~= nil then
boostDirection = player.HumanoidRootPart.CFrame.LookVector
bodyVelocity.Velocity = boostDirection
end
task.wait()
end
I replaced this line bodyVelocity.MaxForce = boostDirection * boostTorque with the line you provided and the it doesnt really move or boost the vehicle…
bodyVelocity.Velocity = boostDirection
There might be no need for it to update cause as I mentioned earlier if I start driving on some other directions other than the “Front”-- basing it using the “View Selector”
local isBoosting = false
local model = script.BodyValue.Value
local exhaust = model.Body:WaitForChild("Boost").Trail0
local boostTorque = 50
local bodyVelocity = Instance.new("BodyVelocity", script.Parent)
bodyVelocity.MaxForce = Vector3.new(0,0,0)
bodyVelocity.Velocity = Vector3.new(0,0,0)
function Boost()
if not isBoosting and script.Parent.Occupant then
isBoosting = true
local player = script.Parent.Occupant.Parent
local boostDirection = player.HumanoidRootPart.CFrame.LookVector
bodyVelocity.MaxForce = boostDirection * boostTorque
for _, v in pairs(exhaust:GetChildren()) do
if v:IsA("Trail") then
v.Enabled = true
end
end
coroutine.wrap(function()
while isBoosting == true do
if player:FindFirstChild("HumanoidRootPart") ~= nil then
boostDirection = player.HumanoidRootPart.CFrame.LookVector
bodyVelocity.Velocity = boostDirection
end
task.wait()
end
end)()
wait(4)
for _, v in pairs(exhaust:GetChildren()) do
if v:IsA("Trail") then
v.Enabled = false
end
end
bodyVelocity.MaxForce = Vector3.new(0, 0, 0)
isBoosting = false
end
end
game.ReplicatedStorage:WaitForChild("Boost").OnServerEvent:Connect(Boost)
Update, I used the script you provided and somehow it now works on the Right Direction but on the Left Direction it just slows down and for the Front it still work but for the back It does the same thing it slows down.
It should work no matter where the player looks, mabye try replacing the code inside the loop with this
if player:FindFirstChild("UpperTorso") ~= nil then
boostDirection = player.UpperTorso.CFrame.LookVector
bodyVelocity.Velocity = Vector3.new(boostDirection.X, 0, boostDirection.Z)
end
It still does the same like the Picture I sent before:
local isBoosting = false
local model = script.BodyValue.Value
local exhaust = model.Body:WaitForChild("Boost").Trail0
local boostTorque = 50
local bodyVelocity = Instance.new("BodyVelocity", script.Parent)
bodyVelocity.MaxForce = Vector3.new(0,0,0)
bodyVelocity.Velocity = Vector3.new(0,0,0)
function Boost()
if not isBoosting and script.Parent.Occupant then
isBoosting = true
local player = script.Parent.Occupant.Parent
local boostDirection = player.HumanoidRootPart.CFrame.LookVector
bodyVelocity.MaxForce = boostDirection * boostTorque
for _, v in pairs(exhaust:GetChildren()) do
if v:IsA("Trail") then
v.Enabled = true
end
end
coroutine.wrap(function()
while isBoosting == true do
if player:FindFirstChild("UpperTorso") ~= nil then
boostDirection = player.UpperTorso.CFrame.LookVector
bodyVelocity.Velocity = Vector3.new(boostDirection.X, 0, boostDirection.Z)
end
task.wait()
end
end)()
wait(4)
for _, v in pairs(exhaust:GetChildren()) do
if v:IsA("Trail") then
v.Enabled = false
end
end
bodyVelocity.MaxForce = Vector3.new(0, 0, 0)
isBoosting = false
end
end
game.ReplicatedStorage:WaitForChild("Boost").OnServerEvent:Connect(Boost)
local isBoosting = false
local model = script.BodyValue.Value
local exhaust = model.Body:WaitForChild("Boost").Trail0
local boostTorque = 50
local bodyVelocity = Instance.new("BodyVelocity", script.Parent)
bodyVelocity.MaxForce = Vector3.new(0,0,0)
bodyVelocity.Velocity = Vector3.new(0,0,0)
function Boost()
if not isBoosting and script.Parent.Occupant then
isBoosting = true
local player = script.Parent.Occupant.Parent
local boostDirection = player.HumanoidRootPart.CFrame.LookVector
bodyVelocity.MaxForce = boostDirection * boostTorque
for _, v in pairs(exhaust:GetChildren()) do
if v:IsA("Trail") then
v.Enabled = true
end
end
coroutine.wrap(function()
while isBoosting == true do
if player:FindFirstChild("HumanoidRootPart") ~= nil then
boostDirection = player.HumanoidRootPart.CFrame.LookVector
bodyVelocity.MaxForce = boostDirection * boostTorque
bodyVelocity.Velocity = boostDirection
end
task.wait()
end
end)()
wait(4)
for _, v in pairs(exhaust:GetChildren()) do
if v:IsA("Trail") then
v.Enabled = false
end
end
bodyVelocity.MaxForce = Vector3.new(0, 0, 0)
isBoosting = false
end
end
game.ReplicatedStorage:WaitForChild("Boost").OnServerEvent:Connect(Boost)
Sorry I forgot to also update the max force
It should work now
local isBoosting = false
local model = script:WaitForChild('BodyValue').Value
local exhaust = model:WaitForChild("Body"):WaitForChild('Trail0')
local boostTorque = 50
local bodyVelocity = Instance.new("BodyVelocity", script.Parent)
bodyVelocity.MaxForce = Vector3.new()
bodyVelocity.Velocity = Vector3.new()
game:GetService("ReplicatedStorage"):WaitForChild("Boost").OnServerEvent:Connect(function(plr)
if isBoosting == false and script.Parent.Occupant ~= nil then
local player = script.Parent.Occupant.Parent
if player ~= nil then
if game:GetService("Players"):GetPlayerFromCharacter(player) == plr then
local human = player:FindFirstChildWhichIsA("Humanoid")
local root = human.RootPart
if root ~= nil then
bodyVelocity.MaxForce = root.CFrame.LookVector * boostTorque
bodyVelocity.Velocity = root.CFrame.LookVector
isBoosting = true
for _, v in pairs(exhaust:GetChildren()) do
if v:IsA("Trail") then
v.Enabled = true
end
end
coroutine.wrap(function()
while isBoosting == true do -- Ignore this error, it's fine
bodyVelocity.MaxForce = root.CFrame.LookVector * boostTorque
bodyVelocity.Velocity = root.CFrame.LookVector
task.wait()
end
end)()
task.wait(4)
isBoosting = false
for _, v in pairs(exhaust:GetChildren()) do
if v:IsA("Trail") then
v.Enabled = false
end
end
bodyVelocity.MaxForce = Vector3.new(0, 0, 0)
end
end
end
end
end)```
Give this a try
It still does the same but I was playing around with the values on the Velocity if its value is positive and the value of the MaxForce is also Positive then both of the directions works fine. currently it is impossible for the values to be turned “Positive” sorry for my bad english.