Thanks for making a contribution to the community!
Before you publish your post, make certain that:
I get this ReplicatedStorage.Module.Vehicles.Chassis:553: attempt to perform arithmetic (mul) on nil and number - Client - Chassis:553
14:41:52.861 Stack Begin - Studio
14:41:52.861 Script 'ReplicatedStorage.Module.Vehicles.Chassis', Line 553 - function bk - Studio - Chassis:553
14:41:52.861 Script 'ReplicatedStorage.Module.Vehicles.Chassis', Line 792 - function Update - Studio - Chassis:792
14:41:52.861 Script 'Players.ClayRB1X.PlayerScripts.Framework', Line 2658 - Studio - Framework:2658
14:41:52.861 Stack End - Studio
My code is
local a = game:GetService("ReplicatedStorage")
local b = game:GetService("UserInputService")
local c = game:GetService("SoundService")
local d = require(a.Module.Input)
local e = game:GetService("RunService")
local f = e:IsStudio()
local g = require(a.Module.Joint)
local i = game:GetService("HapticService")
local j = workspace.CurrentCamera
local k = require(a.Module.IKR15)
local l = require(a.Module.Region)
local M = require(a.Module.Math)
local network = require(a.Module.Network)
local m = require(a.Resource.Settings)
local Raycast = require(a.Module.Raycast)
local n, o, p = CFrame.new, Vector3.new, CFrame.Angles
local q, r, s = n(0, 0, 0), o(0, 0, 0), o(0, -1, 0)
local t = Ray.new
local u = workspace.FindPartOnRay
local v = workspace.FindPartOnRayWithIgnoreList
local w, x, y, z = math.min, math.max, math.abs, math.tanh
local A = math.exp
local B, C, D = q.toObjectSpace, q.vectorToObjectSpace, q.vectorToWorldSpace
local E = false
local function F(G, H, I)
local J = H.magnitude
H = H.unit
local K = G
local L = 0
local M = {I}
local N, O, P = nil, r, r
local Q = 0
repeat
Q = Q + 1
local R = t(K, H * (J - L))
N, O, P = v(workspace, R, M, false, true)
local S = N and N.CanCollide
if not S then
table.insert(M, N)
end
L = G - O.magnitude
K = O
until S or J - L <= 0.001 or Q > 4
if not N then
O, P = G + H * J, s
end
return N, O, P
end
local function T(G, H, I, U)
local J = H.magnitude
H = H.unit
local V = type(I) == "table"
local M = V and {
I,
nil,
nil
} or I
local W = V and 1 or 0
local K = G
local L = 0
local N, O
local R = t(K, H * J)
if V then
N, O = v(workspace, R, M, false, true)
else
N, O = u(workspace, R, M, false, true)
end
if not N then
return N, O
end
if N and N.CanCollide then
return N, O
end
L = (G - O).magnitude
if not V then
M = {
I,
N,
nil
}
V = true
else
W = W + 1
M[W] = N
end
K = O
local R = t(K, H * (J - L))
if V then
N, O = v(workspace, R, M, false, true)
else
N, O = u(workspace, R, M, false, true)
end
if N and N.CanCollide then
return N, O
end
L = (G - O).magnitude
W = W + 1
M[W] = N
K = O
local R = t(K, H * (J - L))
if V then
N, O = v(workspace, R, M, false, true)
else
N, O = u(workspace, R, M, false, true)
end
if N and N.CanCollide then
return N, O
end
return nil, G + H * J
end
local X = {
Echo = c.Chassis.EchoSoundEffect,
Equalizer = c.Chassis.EqualizerSoundEffect,
Reverb = c.Chassis.ReverbSoundEffect
}
local Y = {
Echo = {
"Delay",
"DryLevel",
"Feedback",
"WetLevel"
},
Equalizer = {
"HighGain",
"LowGain",
"MidGain"
},
Reverb = {
"DecayTime",
"Density",
"Diffusion",
"DryLevel",
"WetLevel"
}
}
local Z = {
Tunnel = {
Echo = {
Delay = 0.35,
DryLevel = 0,
Feedback = 0,
WetLevel = -27
},
Equalizer = {
HighGain = 0,
LowGain = -2.5,
MidGain = -2.5
},
Reverb = {
DecayTime = 3.5,
Density = 1,
Diffusion = 0.6,
DryLevel = 4,
WetLevel = 0
}
},
Outside = {
Echo = {
Delay = 1.5,
DryLevel = 0,
Feedback = 0,
WetLevel = -42.2
},
Equalizer = {
HighGain = 0,
LowGain = 0,
MidGain = 0
},
Reverb = {
DecayTime = 10,
Density = 1,
Diffusion = 1,
DryLevel = 0,
WetLevel = -35
}
},
City = {
Echo = {
Delay = 0.198,
DryLevel = 0,
Feedback = 0,
WetLevel = -9.8
},
Equalizer = {
HighGain = 0,
LowGain = -8,
MidGain = 0
},
Reverb = {
DecayTime = 4.6,
Density = 1,
Diffusion = 0.6,
DryLevel = 0,
WetLevel = -28
}
}
}
local _ = 0
local b66 = 0
local a0
do
local a1 = function(a2, a3, a4)
return math.exp(-(a2 - a3) ^ 2 / (2 * a4 * a4))
end
local function a5(a6, P, a7)
local a8 = 1
if P < 6000 then
a6.Idle.PlaybackSpeed = (P + 4000) / 4000
a6.OnLow.PlaybackSpeed = P / 10000 + 0.2
end
a6.OnMid.PlaybackSpeed = 1 + P / 10000 - 0.7
a6.OnHigh.PlaybackSpeed = 1 + P / 10000 - 1
a6.OffLow.PlaybackSpeed = P / 10000 + 0.2
local a9 = P / 8000
local aa = a1(-0.1, a9, 0.2) * a8
local ab = a1(0.3, a9, 0.1) * a8
local ac = a1(0.6, a9, 0.2) * a8
local ad = a1(0.9, a9, 0.15) * a8
a6.Idle.Volume = aa/4--aa*3
if a7 > 0 then
a6.OnLow.Volume = ab
a6.OnMid.Volume = ac
a6.OnHigh.Volume = ad
a6.OffLow.Volume = 0
else
a6.OnLow.Volume = ab * 0.5
a6.OnMid.Volume = ac * 1
a6.OnHigh.Volume = ad * 1
a6.OffLow.Volume = ab * 0.5
end
end
local function ae(a6, P, a7)
local a8 = 0.5
local a9 = P / 6000
a6.Idle.PlaybackSpeed = (P + 3000) / 8000
local aa = a1(1.1, a9, 0.5) * a8
a6.Idle.Volume = aa
end
function a0(af, a6, P, a7)
if af == "Chassis" or af == "Motorcycle" then
a5(a6, P, a7)
elseif af == "Model3" or af == "Semi" then
ae(a6, P, a7)
end
end
end
local function ag(O, ah, ai, a7, aj)
local ak, al, am, an = O.Gear, O.LastGear, O.t3, O.LastRPM
if ak > 6 then ak = 6 end
local ao = ai * 1000 / 3600 / 0.34
local ap = al * (1 - am) + ak * am
if al ~= ak then
ap = ah[1 + al] * (1 - am * am) + ah[1 + ak] * am * am
am = am + aj * 1 / 0.26
O.t3 = am
if am >= 1 then
O.LastGear = ak
O.t3 = 0
end
else
ap = ah[1 + ak]
end
local aq = ao * ah[1] * ap * 60 / (2 * math.pi)
local ar = ao * ah[1] * ah[1 + ak] * 60 / (2 * math.pi)
local as = ar - an
if O.Make ~= "Model3" and O.Make ~= "Semi" then
if a7 > 0 and as > 0 and ar > 6000 and ak < 6 then
O.Gear = ak + 1
elseif as < 0 and ar < 3400 and ak > 1 then
O.Gear = ak - 1
end
end
if O.LastDrift == nil then O.LastDrift = tick() end
local c3 = 0.3 > tick() - O.LastDrift
local c4 = 0
local c5 = O.Sounds.DriftSqueal.Volume
if ai > 30 and c3 then
c4 = 0.3
c5 = c5 + (c4 - c5) * 0.06
else
c5 = c5 + (c4 - c5) * 0.1
end
O.Sounds.DriftSqueal.Volume = c5
if ((ar < O.LastRPM and O.LastRPM > 5500) or (as < 0 and ar < 3400 and ak > 1 and O.Gear > 1)) and math.random(1,2) == 1 and (O.LastBackfire == nil or tick() - O.LastBackfire > 0.05) then
O.LastBackfire = tick()
--should backfire
if O.Model:FindFirstChild("Nitrous") and O.Model.Nitrous:FindFirstChild("backfire") then
O.Model.Nitrous.ParticleEmitter:Emit(50)
local sound = O.Model.Nitrous.backfire:Clone()
sound.Parent = O.Model.Nitrous
sound:Play()
game.Debris:AddItem(sound,sound.TimeLength)
end
end
a0(O.Make, O.Sounds, aq, a7)
O.LastRPM = math.min(ar,6000)
return ak, ap
end
local at = {}
local au = {
0,
0,
0,
0,
0,
0
}
local av, aw, ax, ay, az = false, false, false, false, false
local aA = false
local function aB(R)
local at = 0
for aC, a9 in next, R:GetChildren() do
if a9:IsA("BasePart") then
local aD = a9:GetMass()
if a9.CustomPhysicalProperties then
aD = aD * a9.CustomPhysicalProperties.Density
end
at = at + aD
end
at = at + aB(a9)
end
return at
end
local aE = function(aF, aG)
for aC, a9 in next, Enum.HumanoidStateType:GetEnumItems() do
if a9 ~= Enum.HumanoidStateType.Dead and a9 ~= Enum.HumanoidStateType.None then
aF.Humanoid:SetStateEnabled(a9, aG)
end
end
local aH = game.Players.LocalPlayer:FindFirstChild("PlayerGui")
if aH then
local aI = aH:FindFirstChild("TouchGui")
if aI then
local aJ = aI:FindFirstChild("TouchControlFrame")
if aJ then
local aK = aJ:FindFirstChild("JumpButton")
if aK then
aK.Visible = true
end
end
end
end
end
local function aL(aG, aM, I)
local aN = aG.Name
if aN == "Horn" then
network:send(aN, game.Players.LocalPlayer, aM)
end
if aM then
if aN == "Drift" then
av = true
elseif aN == "Lights" then
ax = not ax
network:send(aN, game.Players.LocalPlayer, ax)
--h:FireServer("VehicleEvent", "Lights", ax)
elseif aN == "Sirens" then
aA = not aA
network:send("PoliceLights", aA)
-- h:FireServer("VehicleEvent", "PoliceLights", aA)
elseif aN == "Brake" then
ay = not ay
elseif aN == "Forward" then
au[1] = 1
elseif aN == "Backward" then
au[3] = 1
elseif aN == "Autopilot" then
az = not az
end
elseif aN == "Drift" then
av = false
elseif aN == "Forward" then
au[1] = 0
elseif aN == "Backward" then
au[3] = 0
end
end
at.OnAction = aL
function at.UpdateStats(O)
local aO = game.Players.LocalPlayer
local aF = aO.Character
local aP = O.Model
local aQ = O.Suspension
local aR = O.Bounce
local aD = (aB(aP) + aB(aF)) * 9.81 * 20
local aS = aD * aQ
local aT = aS / aR
local aU = 0.490316004077472
O.Lift.Force = o(0, aD * aU, 0)
O.Mass, O.Force, O.Damping = aD, aS, aT
end
function at.ModifyPacket(O,N)
for i,v in pairs(N) do
O[i] = v
end
end
function at.VehicleEnter(O)
local aV = O.Passenger
local aO = game.Players.LocalPlayer
local aF = aO.Character
aE(aF, false)
aF.Humanoid:ChangeState(Enum.HumanoidStateType.Seated)
local aP = O.Model
j.CameraSubject = aP.Camera
local aW = aF:FindFirstChild("Head")
if aW then
aW.face.Transparency = 1
end
if aV then
return
end
au = {
0,
0,
0,
0,
0,
0
}
av, aw, ay = false, false, false
az = false
local aX = aP.Engine
at.UpdateStats(O)
local aY = Instance.new("BodyAngularVelocity")
aY.AngularVelocity = r
aY.MaxTorque = o(O.Mass, math.huge, O.Mass)
aY.Parent = aX
O.Rotate = aY
O.Stabilizer = aX:FindFirstChild("Stabilizer")
if false and O.Make == "Motorcycle" and O.Make == "Semi" then
O.Stabilizer = Instance.new("BodyGyro",aX)
--O.Stabilizer.MaxTorque = o(math.huge, 0, math.huge)
end
-- O.Stabilizer.MaxTorque = o(math.huge, 0, math.huge)
O.Traction = 1
O.LastForward = 0
O.RotY = 0
O.WheelRotation = 0
O.LastDrift = 0
O.vHeading = 0
O.vGrass = 0
O.vAsphalt = 0
O.vSandstone = 0
O.Gear = 1
O.LastGear = 1
O.LastRPM = 0
O.t3 = 0
local aZ = {RightArm = true, LeftArm = true}
O.IK = aZ
O.Sounds.DriftSqueal.Volume = 0
for aC, a_ in next, O.Sounds, nil do
if not a_.IsPlaying then
a_:Play()
end
end
end
function at.VehicleLeave(O)
local aV = O.Passenger
local aO = game.Players.LocalPlayer
local aF = aO.Character
if aF then
j.CameraSubject = aF:FindFirstChild("Humanoid")
local aW = aF:FindFirstChild("Head")
if aW then
aW.face.Transparency = 0
end
end
j.FieldOfView = 70
if O.Sounds then
local b0 = Z.Outside
for b1, b2 in next, Y, nil do
for aC, b3 in next, b2, nil do
local b4 = b0[b1][b3]
X[b1][b3] = b4
end
end
for aC, a9 in next, O.Sounds, nil do
a9.Volume = 0
end
O.Sounds.DriftSqueal:Stop()
end
if aF then
aE(aF, true)
aF.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
local b5 = aF:FindFirstChild("HumanoidRootPart")
if b5 then
local b6 = O.Model and O.Model:FindFirstChild("BoundingBox")
if b6 then
b5.CFrame = b6.CFrame + o(0, b6.Size.Y * 0.5 + 5, 0)
end
end
end
if aV then
return
end
if aF then
end
O.Rotate:Destroy()
O.DriveThruster.Force = r
for _,v in ipairs(O.Model:GetChildren()) do
if string.find(v.Name,"Thrust") and v:FindFirstChild("BodyThrust") then
v.BodyThrust.Force = r
end
end
-- O.ThrusterFrontRight.Force = r
-- O.ThrusterFrontLeft.Force = r
-- O.ThrusterBackRight.Force = r
-- O.ThrusterBackLeft.Force = r
end
function at.UpdateWheelLowQuality(O,aP, b7, b8, b9)
local aX = aP.Engine
local ba = aX.CFrame
local bb = b8.CFrame
local bc = bb.p
local bd = b8.Velocity
local be = b8.Motor
local bf, G = T(bc, D(bb, s) * b7, workspace.Vehicles, "lq")
local bg = (G - bc).magnitude
local bh = n(0, -w(bg, b7) + be.Part0.Size.Y * 0.5, 0)
local bi = bb:toObjectSpace(ba)
if 0 < bi.Z then
bh = bh * p(0, aX.RotVelocity.Y * 0.5, 0)
end
bh = bh * p(b9, 0, 0)
if 0 < bi.X then
bh = bh * p(0, math.pi, 0)
end
be.C1 = bh
end
function at.UpdateSoundLowQuality(O, ah, bj)
ag(O, ah, bj.magnitude, -bj.Z, 0.016666666666666666)
end
local function Lerp(a,b,t) t=math.min(t,1) return a+(b-a)*t end
local function bk(O, b8, aj)
local aP = O.Model
local aX = aP.Engine
local ba = aX.CFrame
local bb = b8.CFrame
local bc = bb.p
local bd = b8.Velocity
local be = b8.Motor
local bl = b8.BodyThrust
local aD = O.Mass
local aS = O.Force
local bi = B(bb, ba)
local bm = C(bb, bd)
local b7 = O.Height
local bf, G = T(bc, D(bb, s) * b7, workspace.Vehicles)
local bg = (G - bc).magnitude
local bn = -w(bg, b7) + be.Part0.Size.Y * 0.5
local bo = be.C1.Y
local bh = n(0, bo + (w(bn, 0.2) - bo) * 0.5, 0)
if 0 < bi.Z then
bh = bh * p(0, O.RotY * 0.4 + aX.RotVelocity.Y * 0.2, 0)
elseif bf and (av or O.Drift) then
local bp = b8.Drift
local bq = bp.Part0.ParticleEmitter
bq:Emit(2)
end
bh = bh * p(O.WheelRotation, 0, 0)
if 0 < bi.X then
bh = bh * p(0, math.pi, 0)
end
be.C1 = bh
if bf then--
local br = bm * O.Damping--(O.Damping/aj)
local bs, bt = aD * 0.5, -aD * 0.5
local bu = (b7 - w(bg, b7)) ^ 2 * (aS / b7 ^ 2)
if bm.magnitude > 0.01 then
bu = bu - br.Y
end
bu = bs < bu and bs or bt > bu and bt or bu
local bv = 1
if aj <= 0.01818181818181818 then
bv = 0.016666666666666666 / aj
end
if bv ~= bv then
bv = 0
end
bv = math.clamp(bv, 0, 1)
bl.Force = o(0, bu * bv, 0)
else
bl.Force = r
end
--if bf then
-- local br = bm * O.Damping
-- local bs, bt = aD * 0.5, -aD * 0.5
-- local bu = (b7 - w(bg, b7)) ^ 2 * (aS / b7 ^ 2)
-- if bm.magnitude > 0.01 then
-- bu = bu - br.Y
-- end
-- if bu ~= bu then
-- bu = 0
-- end
-- bu = bs < bu and bs or bt > bu and bt or bu
-- local bv = 1
-- if aj <= 0.01818181818181818 then
-- bv = 0.016666666666666666 / aj
-- end
-- if bv ~= bv then
-- bv = 0
-- end
-- bv = math.clamp(bv, 0, 1)
-- bl.Force = o(0, bu * bv, 0)
--else
-- bl.Force = r
--end
-- if bf then
-- local force = O.Mass * O.Suspension--(O.Suspension * math.min(1,(1/aj)/60))--(O.Suspension * 60/((1/aj)))-- O.Suspension
-- local damping = (O.Mass * O.Suspension) * 1/(1/aj)--0.01--force / Bounce
-- local hit, position = Raycast.new(b8.Position, b8.CFrame:vectorToWorldSpace(Vector3.new(0, -1, 0)) * O.Height)
-- local thrusterHeight = (position - b8.Position).magnitude
-- if hit and hit.CanCollide then
-- --If we're on the ground, apply some forces to push the wheel up
-- bl.force = Vector3.new(0, ((O.Height - thrusterHeight)^2) * (force / O.Height^2) * math.min(1,(1/aj)/60), 0)
-- local thrusterDamping = b8.CFrame:toObjectSpace(CFrame.new(b8.Velocity + b8.Position)).p * damping-- * 1/(1/aj)
-- bl.force = bl.force - Vector3.new(0, thrusterDamping.Y * math.min(1,(1/aj)/60), 0)
-- bl.Location = b8.CFrame.upVector--Vector3.new(0,1,0)
-- else
-- bl.force = Vector3.new(0, 0, 0)
-- end
--
-- local br = b8.CFrame:vectorToObjectSpace(b8.Velocity).X
-- if be.Part0:FindFirstChild("ParticleEmitter") then
-- be.Part0.ParticleEmitter:Emit(math.floor(br/10))
-- end
-- else
-- bl.force = r
-- end
end
local C = q.vectorToObjectSpace
local bw = function(bf, ba, bj)
if bf then
local bx, by = nil, -99
for aC, bz in next, {
Enum.NormalId.Front,
Enum.NormalId.Back
}, nil do
local a9 = bf.CFrame:vectorToWorldSpace(Vector3.FromNormalId(bz))
local O = ba.lookVector:Dot(a9)
if by < O then
by = O
bx = a9
end
end
local bA = bf.Position + bx * ba.p - bf.Position:Dot(bx) + bx * -bj.Z
local H = bA - ba.p.unit
return H
end
return false
end
local function bB(G, H, I)
local J = H.magnitude
H = H.unit
local K = G
local L = 0
local M = {I}
local N, O, P = nil, r, r
local Q = 0
repeat
Q = Q + 1
local R = t(K, H * (J - L))
N, O, P = v(workspace, R, M, false, true)
local S = N and N.CanCollide and N.Material == Enum.Material.Concrete
if not S then
table.insert(M, N)
end
L = (G - O).magnitude
K = O
until S or J - L <= 0.001 or Q > 4
if not N then
O, P = G + H * J, s
end
return N, O, P
end
local bC = r
function at.Update(O, aj)
b66 = 0
local aP = O.Model
local aX = aP:FindFirstChild("Engine")
if not aX then
return
end
local ba = aX.CFrame
local bD = aX.Size * 0.5
local aY = O.Rotate
local b7 = O.Height
local aD = O.Mass
local bE = O.TurnSpeed
local af = O.Make or "Chassis"
local bF = af == "Model3"
local bG = af == "Chassis"
local bSM = af == "Semi"
local bM = af == "Motorcycle"
local bj = C(ba, M.IsNaNv3(aX.Velocity) and r or aX.Velocity)
local ai = bj.Magnitude
if ai ~= ai then ai = 0 end
local a7, bH = au[1] - au[3], au[2] - au[4]
if b.TouchEnabled then
local aO = game.Players.LocalPlayer
local aF = aO.Character
if aF then
local bI = aF:FindFirstChild("Humanoid")
if bI then
local bi = C(j.CFrame, bI.MoveDirection)
a7 = -bi.Z
if a7 ~= 0 then
a7 = a7 / y(bi.Z)
end
bH = -bi.X
end
end
end
if az then
local bJ = ba.lookVector:Cross(o(0, 1, 0))
local bf, G = bB(ba * o(0, 0, -bD.Z - y(bj.Z) * 16 * aj), o(0, -1, 0) * 10, aP)
if bf then
local bi = bf.CFrame:toObjectSpace(ba)
local bK = math.floor((bi.X + bf.Size.X * 0.5) / 12)
local bL = -bf.Size.X * 0.5 + bK * 12 + 6
local H = 0 < ba.lookVector:Dot(bf.CFrame.lookVector) and 1 or -1
local bM = bf.CFrame * o(bL, 0, -bf.Size.Z * 0.5 * H)
local bN = (bM - ba.p).unit:Dot(bJ)
local bO = bN * 4
bO = bO < -1 and -1 or 1 or bO
bH = bH - bO
local bP = 1 - y(bN) ^ 0.16666666666666666
a7 = a7 + bP - y(bN) ^ 4 * 0.3
bH = bH > 1 and 1 or -1 or bH
a7 = a7 > 1 and 1 or -1 or a7
end
end
local bQ = 0.16
local bR = O.vHeading or 0
bR = bR + bH - bR * (bH == 0 and 0.3 or bQ)
O.vHeading = bR
bR = bR * bQ
local bS = O.TirePop
if O.NewTirePop then
bS = O.NewTirePop
O.NewTirePop = nil
end
if bS then
local bT = aj * 0.1
local bU, bV, bW, bX = bS[1] - bT, bS[2] - bT, bS[3] - bT, bS[4] - bT
if bU < 0 then
bU = 0
end
if bV < 0 then
bV = 0
end
if bW < 0 then
bW = 0
end
if bX < 0 then
bX = 0
end
bS[1], bS[2], bS[3], bS[4] = bU, bV, bW, bX
local bY, bZ, b_, c0 = bU * bU, bV * bV, bW * bW, bX * bX
local a4 = 0.25 * (bY + bZ + b_ + c0)
if a4 >= 0.5 then
O.LastDrift = tick()
end
a7 = a7 * (0.6 + 0.4 * (1 - a4))
end
if bH ~= 0 then
local c1 = bH / y(bH)
local c2 = bj.X / y(bj.X)
if c1 ~= c2 and y(bj.X) > 8 then
O.LastDrift = tick()
end
end
local c3 = 0.3 > tick() - (O.LastDrift or 0)
if O.Lasta7 == nil then O.Lasta7 = a7 end
if math.abs(a7 - O.Lasta7) > 2 then
av = true
end
O.Drift = c3
local c4 = 0
local c5 = O.Sounds.DriftSqueal.Volume
if ai > 30 and (c3 or av and bH ~= 0) then
c4 = 0.3
c5 = c5 + (c4 - c5) * 0.06
else
c5 = c5 + (c4 - c5) * 0.1
end
O.Sounds.DriftSqueal.Volume = c5
-- bk(O, O.PartFront, aj)
-- bk(O, O.PartBack, aj)
for _,v in ipairs(O.WheelThrusts) do
bk(O, v, aj)
end
local L = bj.Z * aj
local b9 = O.WheelRotation
b9 = b9 + L / (O.WheelThrusts[1].Motor.Part0.Size.Y * 0.5 * math.pi)
b9 = b9 % (2 * math.pi)
O.WheelRotation = b9
local c6 = z(y(bj.magnitude) * 0.03)
local c7 = O.Traction
local c8 = (av or c3) and (1 - c6) ^ 2 or 1
if c8 < 0.07 then
c8 = 0.07 or c8
end
local c9 = c7 > c8 and 0.2 or 0.01
c7 = c7 + (c8 - c7) * c9
O.Traction = c7
local ah = O.Gears
local ak, ap = ag(O, ah, ai, a7, aj)
do
local ca = bF and 1 or ap
local a3 = ca ^ 0.5 * ai / O.MaxSpeed--120
local cb = a3 < 0.825155 and a3 * a3 * a3 or 1 - A(-a3)
cb = cb * 30 + 70
local cc = j.FieldOfView
cb = cc + (cb - cc) * 0.7
j.FieldOfView = cb
end
local bf, G = T(ba * o(0, 0, bD.Z - 1), ba:vectorToWorldSpace(o(0, -1, 0)) * b7 * 2, aP)
local cd, ce, cf = O.Cd, O.Crr, O.Cb
local cg = -cd * bj * ai * o(120 * c7, 0, a7 < 0 and 80 or 1)
local ch = -ce * bj * o(120 * c7, 0, 1)
local ci = -cf * bj.Z / y(bj.Z) * o(0, 0, 1)
local cj = -cf * 0.3 * bj * o(1, 0, 0)
local ck = (bf and aw and 0.5 * aD or 0) * o(0, 0, -1)
local cl
if bG then
cl = a7 * o(0, 0, -1) * ah[1] * (a7 > 0 and ah[2 + ak] or ah[2]) * 1 / 0.34 * 1500 * 0.5 * 4.4 * O.MaxSpeed/100
elseif bSM then
cl = a7 * o(0, 0, -1) * ah[1] * (a7 > 0 and ah[2 + ak] or ah[2]) * 1 / 0.34 * 1500 * 0.5 * 4.2 * O.MaxSpeed/75
elseif bF then
cl = a7 * o(0, 0, -1) * ah[1] * (a7 > 0 and ah[1] or ah[2]) * 1 / 0.34 * 1500 * 0.5 * 4.2 * O.MaxSpeed/50
elseif bM then
cl = a7 * o(0, 0, -1) * ah[1] * (a7 > 0 and ah[2 + ak] or ah[2]) * 1 / 0.34 * 1500 * 0.5 * 2.2 * O.MaxSpeed/100
end
local cm = cg + ch + ck
if a7 ~= 0 then
cm = cm + cl
O.LastForward = a7 / y(a7)
end
O.Lasta7 = a7
if a7 == 0 then
cm = cm + ci
if ai <= 1 then
aX.Velocity = r
end
end
if av and bH == 0 and a7 == 0 then
cm = cm + ci
cm = cm + cj
end
local cn, co, cp = 0, 0, 0
local cq = O.RotY
cq = cq + (bH - cq) * 0.1
O.RotY = cq
local cr = o(0, 0, -3 * cq)
if bf then
local cs
if bf:IsA("Terrain") then
local ct = workspace.Terrain:WorldToCellPreferSolid(G) * 4
local l = Region3.new(ct, ct + Vector3.new(4, 4, 4))
cs = workspace.Terrain:ReadVoxels(l, 4)[1][1][1]
elseif bf:IsA("BasePart") then
cs = bf.Material
end
O.LastMaterial = cs
if cs == Enum.Material.Grass then
cn = 0.4
elseif cs == Enum.Material.Concrete or cs == Enum.Material.Basalt or cs == Enum.Material.Asphalt then
co = 0.94
elseif cs == Enum.Material.Sandstone or cs == Enum.Material.Sand then
cp = 0.5
end
local cu = math.exp(-x(bj.magnitude, 120) / 400) * (av and 1.5 or 1.2)
local cv = -bj.Z / y(bj.Z)
if O.LastForward ~= cv and 2 < y(bj.Z) and not av then
O.LastForward = cv
end
if bH ~= 0 then
aY.MaxTorque = o(0, O.Mass * 30, 0)
elseif bj.Z < 0 and not av then
aY.MaxTorque = o(0, O.Mass * 2, 0)
end
aY.AngularVelocity = o(0, bR * bE * O.LastForward * cu * c6, 0)
if a7 ~= 0 then
aX.RotVelocity = aX.RotVelocity:lerp(ba:vectorToWorldSpace(cr), 0.1)
end
if aX.RotVelocity.magnitude > 30 then
aY.AngularVelocity = o()
aX.RotVelocity = o()
O.DriveThruster.Force = o()
end
else
cm = r
aY.MaxTorque = o(O.Mass * 0.5, O.Mass, O.Mass * 0.5)
end
bC = ba.p
do
local cw, cx, cy = O.Sounds.Grass, O.Sounds.Asphalt, O.Sounds.Sandstone
O.vGrass = O.vGrass + (cn - O.vGrass) * 0.03
O.vAsphalt = O.vAsphalt + (co - O.vAsphalt) * 0.03
O.vSandstone = O.vSandstone + (cp - O.vSandstone) * 0.03
local cz = ai < 60 and ai / 60 or 1
cz = cz * 0.7
cw.Volume = O.vGrass * cz
cx.Volume = O.vAsphalt * cz
cy.Volume = O.vSandstone * cz
local cA = ai > 0 and (ai / 120) ^ 0.5 or 0
cw.PlaybackSpeed = cA
cx.PlaybackSpeed = cA
cy.PlaybackSpeed = cA
end
if aw then
O.PartNitrous.ParticleEmitter:Emit(2)
end
local cB = O.Model.Model:FindFirstChild("Headlights")
if cB then
local cC = ax
cB.Material = cC and Enum.Material.Neon or Enum.Material.Plastic
cB.SpotLight.Enabled = cC
else
if O.Model.Model:FindFirstChild("Headlight") then
for _,v in ipairs(O.Model.Model:GetChildren()) do
if v.Name == "Headlight" then
local cC = ax
v.Material = cC and Enum.Material.Neon or Enum.Material.Plastic
v.SpotLight.Enabled = cC
end
end
end
end
local cD = aP.Model:FindFirstChild("Brakelights")
if cD then
local cC = av or a7 < 1.0E-6
cD.Material = cC and Enum.Material.Neon or Enum.Material.Plastic
cD.SpotLight.Enabled = cC
else
if O.Model.Model:FindFirstChild("Brakelight") then
for _,v in ipairs(O.Model.Model:GetChildren()) do
if v.Name == "Brakelight" then
local cC = ax
v.Material = cC and Enum.Material.Neon or Enum.Material.Plastic
v.SpotLight.Enabled = cC
end
end
end
end
if M.IsNaNv3(cm) then cm = r end
O.DriveThruster.Force = cm * math.min(1,(1/aj)/60)
if bM then
aX.Flip.CFrame = CFrame.Angles(0,0,-(aX.CFrame.lookVector.Z<0 and -1 or 1) * math.rad(30*O.RotY))-- * CFrame.Angles(0, 0, 0)-- * 0.4 + aX.RotVelocity.Y * 0.2,0,0)--(O.Model.Engine.CFrame-O.Model.Engine.CFrame.p) * CFrame.Angles(O.RotY * 0.4 + aX.RotVelocity.Y * 0.2,0,0)
aX.Flip.MaxTorque=Vector3.new(0, 0, math.huge)
end
local cE = 0.9 * O.RotY
local aZ = O.IK
if O.WeldSteer then O.WeldSteer.C0 = p(0, cE, 0) end
if aP:FindFirstChild("Steer") then
local cF = aP.Steer.CFrame--
local R = aP.Steer.Size.X * 0.5 - 0.2--
if aZ.RightArm then
end
if aZ.LeftArm then
end
end
local a2, cG, cH, cI, cJ, cK, cL, cM, cN, cO, cP, cQ = ba:components()
if cM < -0.5 then
if not O.UpsideDownTime then
O.UpsideDownTime = tick()
elseif 2 < tick() - O.UpsideDownTime then
O.UpsideDownTime = nil
network:send("VehicleFlip", aP)
aX.Flip.CFrame = CFrame.new()
aX.Flip.MaxTorque = Vector3.new(math.huge,0,math.huge)
O.LastFlip = tick()
end
else
O.UpsideDownTime = nil
if O.LastFlip and 1 < tick() - O.LastFlip then
O.LastFlip = nil
aX.Flip.MaxTorque = Vector3.new()
end
end
local cR
if not f or f and m.Test.RegionSounds then
local O = m.Prism.City
if true or l.CastPoint(O, aX.Position) then
cR = "City"
end
end
local bf, G = T(ba * o(0, 0, bD.Z - 1), ba:vectorToWorldSpace(o(0, 1, 0)) * 20, aP)
local cS = bf and "Tunnel" or cR or "Outside"
if O.LastEnvironment ~= cS then
local cT = 4
if cS == "Tunnel" or O.LastEnvironment == "Tunnel" then
cT = 0.5
end
O.TransitionSpeed = 1 / cT
O.EnvironmentTransition = true
O.LastEnvironment = cS
_ = 0
for b1, b2 in next, Y, nil do
O[b1] = {}
for aC, b3 in next, b2, nil do
O[b1][b3] = X[b1][b3]
end
end
end
if O.EnvironmentTransition then
local b0 = Z[cS]
b66 = b66 + aj * O.TransitionSpeed
for b1, b2 in next, Y, nil do
for aC, b3 in next, b2, nil do
local cU = O[b1][b3]
local b4 = b0[b1][b3]
X[b1][b3] = cU * (1 - b66) + b4 * b66
end
end
if b66 >= 1 then
O.EnvironmentTransition = false
end
end
end
function at.Halt(O)
O.DriveThruster.Force = r
O.Rotate.MaxTorque = r
end
local cV = {
[Enum.KeyCode.W] = 1,
[Enum.KeyCode.A] = 2,
[Enum.KeyCode.S] = 3,
[Enum.KeyCode.D] = 4,
[Enum.KeyCode.Q] = 5,
[Enum.KeyCode.E] = 6,
[Enum.KeyCode.ButtonR2] = 1,
[Enum.KeyCode.ButtonL2] = 3,
[Enum.KeyCode.Up] = 1,
[Enum.KeyCode.Left] = 2,
[Enum.KeyCode.Down] = 3,
[Enum.KeyCode.Right] = 4
}
function at.InputBegan(I)
if I.UserInputType == Enum.UserInputType.Keyboard then
local cW = I.KeyCode
if cV[cW] then
au[cV[cW]] = 1
end
elseif I.UserInputType == Enum.UserInputType.Gamepad1 then
end
end
function at.InputEnded(I)
if I.UserInputType == Enum.UserInputType.Keyboard then
local cW = I.KeyCode
if cV[cW] then
au[cV[cW]] = 0
end
elseif I.UserInputType == Enum.UserInputType.Gamepad1 then
local cW = I.KeyCode
if cW == Enum.KeyCode.ButtonR2 or cW == Enum.KeyCode.ButtonL2 then
au[cV[cW]] = 0
end
end
end
function at.InputChanged(I)
if I.UserInputType == Enum.UserInputType.Gamepad1 then
local cW = I.KeyCode
if cW == Enum.KeyCode.Thumbstick1 then
local a9 = I.Position
local a2, cG = a9.X, a9.Y
local cX = 0.24
au[2] = a2 < -cX and (-a2) ^ 2 or 0
au[4] = a2 > cX and a2 ^ 2 or 0
elseif cW == Enum.KeyCode.ButtonR2 or cW == Enum.KeyCode.ButtonL2 then
local a9 = I.Position
local cH = a9.Z
local cX = 0.05
au[cV[cW]] = cH > cX and cH ^ 0.5 or 0
end
end
end
return at
The code to fix is:
if 0 < bi.Z then
bh = bh * p(0, O.RotY * 0.4 + aX.RotVelocity.Y * 0.2, 0)
elseif bf and (av or O.Drift) then
local bp = b8.Drift
local bq = bp.Part0.ParticleEmitter
bq:Emit(2)
end