Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can i make lookvector stable?

Asked by 5 years ago

So i made a car that is runned with a bodyvelocity. and its velocity is set to the vehicles seats lookvector. but if i drive it, it always slides left or right and isnt in a straight line. but if i reach the maximum speed, its stable, and goes in a straight line. can someone explain? thanks script:

local s = script.Parent
local car = s.Parent
local stats = car.Base.Stats

local function changed(pro)
    if pro == "Throttle" then
        car.Base.BodyVelocity.MaxForce = Vector3.new(stats.Acceleration.Value, 0,stats.Acceleration.Value) * 7000
        car.Base.BodyVelocity.Velocity = car.DriverSeat.CFrame.LookVector * s.Throttle * stats.TopSpeed.Value
    end
        if pro == "Steer" then
        car.Base.BodyAngularVelocity.AngularVelocity = Vector3.new(0,-stats.TurnSpeed.Value,0) * s.Steer
        end
end
s.Changed:Connect(changed)

while true do
    car.Base.BodyVelocity.Velocity = car.DriverSeat.CFrame.LookVector * s.Throttle * stats.TopSpeed.Value
    wait()
end

Answer this question