script.Parent:WaitForChild("\065-\067\104\097\115\115\105\115 \073\110\116\101\114\102\097\099\101")script.Parent:WaitForChild("\080\108\117\103\105\110\115")script.Parent:WaitForChild("\082\069\065\068\077\069")local n=script.Parent.Parent local D=require(script.Parent)local i=n.Wheels:GetChildren()function getParts(n,D,i)for n,E in pairs(n:GetChildren())do if E:IsA("\066\097\115\101\080\097\114\116")then table.insert(D,{E,i.CFrame:toObjectSpace(E.CFrame)})elseif E:IsA("\077\111\100\101\108")then getParts(E,D,i)end end end for i,E in pairs(i)do for n,D in pairs({"\084\111\112","\066\111\116\116\111\109","\076\101\102\116","\082\105\103\104\116";"\070\114\111\110\116";"\066\097\099\107"})do E[D.."\083\117\114\102\097\099\101"]=Enum.SurfaceType.SmoothNoOutlines end local L={}local W=E.Position-n.DriveSeat.Position if E.Name=="\070\076"or E.Name=="\082\076"then E.CFrame=n.DriveSeat.CFrame*CFrame.Angles(math.rad(90),0,math.rad(90))else E.CFrame=n.DriveSeat.CFrame*CFrame.Angles(math.rad(90),0,math.rad(-90))end E.CFrame=E.CFrame+W if E:FindFirstChild("\080\097\114\116\115")~=nil then getParts(E.Parts,L,E)end if E:FindFirstChild("\070\105\120\101\100")~=nil then getParts(E.Fixed,L,E)end if E.Name=="\070\076"or E.Name=="\070\082"then E.CFrame=E.CFrame*CFrame.Angles(math.rad(D.FCamber),0,0)if E.Name=="\070\076"then E.CFrame=E.CFrame*CFrame.Angles(0,0,math.rad(D.FToe))else E.CFrame=E.CFrame*CFrame.Angles(0,0,math.rad(-D.FToe))end elseif E.Name=="\082\076"or E.Name=="\082\082"then E.CFrame=E.CFrame*CFrame.Angles(math.rad(D.RCamber),0,0)if E.Name=="\082\076"then E.CFrame=E.CFrame*CFrame.Angles(0,0,math.rad(D.RToe))else E.CFrame=E.CFrame*CFrame.Angles(0,0,math.rad(-D.RToe))end end for n,D in pairs(L)do D[1].CFrame=E.CFrame:toWorldSpace(D[2])end if E.Name=="\070\076"then E.CFrame=E.CFrame*CFrame.Angles(0,math.rad(-D.FCaster),0)elseif E.Name=="\070\082"or E.Name=="\070"then E.CFrame=E.CFrame*CFrame.Angles(0,math.rad(D.FCaster),0)elseif E.Name=="\082\076"then E.CFrame=E.CFrame*CFrame.Angles(0,math.rad(-D.RCaster),0)elseif E.Name=="\082\082"or E.Name=="\082"then E.CFrame=E.CFrame*CFrame.Angles(0,math.rad(D.RCaster),0)end local X=Instance.new("\080\097\114\116",E)X.Name="\065\114\109"X.Anchored=true X.CanCollide=false X.FormFactor=Enum.FormFactor.Custom X.Size=Vector3.new(1,1,1)X.CFrame=(E.CFrame*CFrame.new(0,D.StAxisOffset,0))*CFrame.Angles(-math.pi/2,-math.pi/2,0)X.TopSurface=Enum.SurfaceType.Smooth X.BottomSurface=Enum.SurfaceType.Smooth X.Transparency=1 local A=X:Clone()A.Parent=E A.Name="\066\097\115\101"A.CFrame=A.CFrame*CFrame.new(0,1,0)A.BottomSurface=Enum.SurfaceType.Hinge local s=X:Clone()s.Parent=E s.Name="\065\120\108\101"s.CFrame=CFrame.new(E.Position-(E.CFrame*CFrame.Angles(math.pi/2,0,0)).lookVector*(E.Size.x/2+s.Size.x/2),E.Position)*CFrame.Angles(0,math.pi,0)s.BackSurface=Enum.SurfaceType.Hinge if E.Name=="\070"or E.Name=="\082"then local n=X:Clone()n.Parent=E n.Name="\065\120\108\101"n.CFrame=CFrame.new(E.Position+(E.CFrame*CFrame.Angles(math.pi/2,0,0)).lookVector*(E.Size.x/2+n.Size.x/2),E.Position)*CFrame.Angles(0,math.pi,0)n.BackSurface=Enum.SurfaceType.Hinge MakeWeld(X,n)end MakeWeld(n.DriveSeat,A)if E.Parent.Name=="\082\076"or E.Parent.Name=="\082\082"or E.Name=="\082"then MakeWeld(n.DriveSeat,X)end MakeWeld(X,s)X:MakeJoints()s:MakeJoints()if E:FindFirstChild("\070\105\120\101\100")~=nil then ModelWeld(E.Fixed,s)end if E:FindFirstChild("\080\097\114\116\115")~=nil then ModelWeld(E.Parts,E)end if E:FindFirstChild("\083\116\101\101\114")then(E:FindFirstChild("\083\116\101\101\114")):Destroy()end local p=Instance.new("\066\111\100\121\071\121\114\111",E)p.Name="\083\116\097\098\105\108\105\122\101\114"if E.Name=="\070\076"or E.Name=="\070\082"or E.Name=="\070"then p.D=D.FGyroD p.MaxTorque=D.FGyroMaxTorque p.P=D.FGyroP else p.D=D.RGyroD p.MaxTorque=D.RGyroMaxTorque p.P=D.RGyroP end if E.Name=="\070\076"or E.Name=="\070\082"or E.Name=="\070"then local n=Instance.new("\066\111\100\121\071\121\114\111",X)n.Name="\083\116\101\101\114"n.P=D.SteerP n.D=D.SteerD n.MaxTorque=Vector3.new(0,D.SteerMaxTorque,0)n.cframe=A.CFrame else MakeWeld(A,s,"\087\101\108\100")end local a=Instance.new("\066\111\100\121\065\110\103\117\108\097\114\086\101\108\111\099\105\116\121",E)a.Name="\035\065\086"a.angularvelocity=Vector3.new(0,0,0)a.maxTorque=Vector3.new(D.PBrakeForce,0,D.PBrakeForce)a.P=1000000000.0 end for n,D in pairs(script:GetChildren())do if D:IsA("\077\111\100\117\108\101\083\099\114\105\112\116")then require(D)end end wait()ModelWeld(n.Body,n.AirSetup)local E=Instance.new("\066\111\100\121\071\121\114\111",n.DriveSeat)E.Name="\070\108\105\112"E.D=0 E.MaxTorque=Vector3.new(0,0,0)E.P=0 wait()UnAnchor(n)script.Parent["\065-\067\104\097\115\115\105\115 \073\110\116\101\114\102\097\099\101"].Car.Value=n for D,i in pairs(script.Parent.Plugins:GetChildren())do for D,i in pairs(i:GetChildren())do if i:IsA("\082\101\109\111\116\101\069\118\101\110\116")or i:IsA("\082\101\109\111\116\101\070\117\110\099\116\105\111\110")then i.Parent=n for n,D in pairs(i:GetChildren())do if D:IsA("\083\099\114\105\112\116")then D.Disabled=false end end end end i.Parent=script.Parent["\065-\067\104\097\115\115\105\115 \073\110\116\101\114\102\097\099\101"]end script.Parent.Plugins:Destroy()n.DriveSeat.ChildAdded:connect(function(D)if D.Name=="\083\101\097\116\087\101\108\100"and(D:IsA("\087\101\108\100")and game.Players:GetPlayerFromCharacter(D.Part1.Parent)~=nil)then local i=game.Players:GetPlayerFromCharacter(D.Part1.Parent)n.DriveSeat:SetNetworkOwner(i)local E=script.Parent["\065-\067\104\097\115\115\105\115 \073\110\116\101\114\102\097\099\101"]:Clone()E.Parent=i.PlayerGui end end)n.DriveSeat.ChildRemoved:connect(function(D)if D.Name=="\083\101\097\116\087\101\108\100"and D:IsA("\087\101\108\100")then for n,D in pairs(n.DriveSeat:GetChildren())do if D:IsA("\083\111\117\110\100")then D:Stop()end end if n.DriveSeat:FindFirstChild("\070\108\105\112")~=nil then n.DriveSeat.Flip.MaxTorque=Vector3.new()end for n,D in pairs(n.Wheels:GetChildren())do if D:FindFirstChild("\035\065\086")~=nil then if D["\035\065\086"].AngularVelocity.Magnitude>0 then D["\035\065\086"].AngularVelocity=Vector3.new()D["\035\065\086"].MaxTorque=Vector3.new()end end end end end)ver=require(script.Parent.README)
--
script.Parent:WaitForChild("A-Chassis Interface")
script.Parent:WaitForChild("Plugins")
script.Parent:WaitForChild("README")

local car = script.Parent.Parent
local _Tune = require(script.Parent)

local Drive = car.Wheels:GetChildren()

function getParts(model, t, a)
	for i, v in pairs(model:GetChildren()) do
		if v:IsA("BasePart") then
			table.insert(t, { v, a.CFrame:toObjectSpace(v.CFrame) })
		elseif v:IsA("Model") then
			getParts(v, t, a)
		end
	end
end

for _, v in pairs(Drive) do
	for _, a in pairs({ "Top", "Bottom", "Left", "Right", "Front", "Back" }) do
		v[a .. "Surface"] = Enum.SurfaceType.SmoothNoOutlines
	end

	local WParts = {}

	local tPos = v.Position - car.DriveSeat.Position
	if v.Name == "FL" or v.Name == "RL" then
		v.CFrame = car.DriveSeat.CFrame * CFrame.Angles(math.rad(90), 0, math.rad(90))
	else
		v.CFrame = car.DriveSeat.CFrame * CFrame.Angles(math.rad(90), 0, math.rad(-90))
	end
	v.CFrame = v.CFrame + tPos

	if v:FindFirstChild("Parts") ~= nil then
		getParts(v.Parts, WParts, v)
	end
	if v:FindFirstChild("Fixed") ~= nil then
		getParts(v.Fixed, WParts, v)
	end

	if v.Name == "FL" or v.Name == "FR" then
		v.CFrame = v.CFrame * CFrame.Angles(math.rad(_Tune.FCamber), 0, 0)
		if v.Name == "FL" then
			v.CFrame = v.CFrame * CFrame.Angles(0, 0, math.rad(_Tune.FToe))
		else
			v.CFrame = v.CFrame * CFrame.Angles(0, 0, math.rad(-_Tune.FToe))
		end
	elseif v.Name == "RL" or v.Name == "RR" then
		v.CFrame = v.CFrame * CFrame.Angles(math.rad(_Tune.RCamber), 0, 0)
		if v.Name == "RL" then
			v.CFrame = v.CFrame * CFrame.Angles(0, 0, math.rad(_Tune.RToe))
		else
			v.CFrame = v.CFrame * CFrame.Angles(0, 0, math.rad(-_Tune.RToe))
		end
	end

	for _, a in pairs(WParts) do
		a[1].CFrame = v.CFrame:toWorldSpace(a[2])
	end

	if v.Name == "FL" then
		v.CFrame = v.CFrame * CFrame.Angles(0, math.rad(-_Tune.FCaster), 0)
	elseif v.Name == "FR" or v.Name == "F" then
		v.CFrame = v.CFrame * CFrame.Angles(0, math.rad(_Tune.FCaster), 0)
	elseif v.Name == "RL" then
		v.CFrame = v.CFrame * CFrame.Angles(0, math.rad(-_Tune.RCaster), 0)
	elseif v.Name == "RR" or v.Name == "R" then
		v.CFrame = v.CFrame * CFrame.Angles(0, math.rad(_Tune.RCaster), 0)
	end

	local arm = Instance.new("Part", v)
	arm.Name = "Arm"
	arm.Anchored = true
	arm.CanCollide = false
	arm.FormFactor = Enum.FormFactor.Custom
	arm.Size = Vector3.new(1, 1, 1)
	arm.CFrame = (v.CFrame * CFrame.new(0, _Tune.StAxisOffset, 0)) * CFrame.Angles(-math.pi / 2, -math.pi / 2, 0)
	arm.TopSurface = Enum.SurfaceType.Smooth
	arm.BottomSurface = Enum.SurfaceType.Smooth
	arm.Transparency = 1

	local base = arm:Clone()
	base.Parent = v
	base.Name = "Base"
	base.CFrame = base.CFrame * CFrame.new(0, 1, 0)
	base.BottomSurface = Enum.SurfaceType.Hinge

	local axle = arm:Clone()
	axle.Parent = v
	axle.Name = "Axle"
	axle.CFrame = CFrame.new(
		v.Position - ((v.CFrame * CFrame.Angles(math.pi / 2, 0, 0)).lookVector * ((v.Size.x / 2) + (axle.Size.x / 2))),
		v.Position
	) * CFrame.Angles(0, math.pi, 0)
	axle.BackSurface = Enum.SurfaceType.Hinge

	if v.Name == "F" or v.Name == "R" then
		local axle2 = arm:Clone()
		axle2.Parent = v
		axle2.Name = "Axle"
		axle2.CFrame = CFrame.new(
			v.Position + (
					(v.CFrame * CFrame.Angles(math.pi / 2, 0, 0)).lookVector * ((v.Size.x / 2) + (axle2.Size.x / 2))
				),
			v.Position
		) * CFrame.Angles(0, math.pi, 0)
		axle2.BackSurface = Enum.SurfaceType.Hinge
		MakeWeld(arm, axle2)
	end

	MakeWeld(car.DriveSeat, base)
	if v.Parent.Name == "RL" or v.Parent.Name == "RR" or v.Name == "R" then
		MakeWeld(car.DriveSeat, arm)
	end

	MakeWeld(arm, axle)

	arm:MakeJoints()
	axle:MakeJoints()

	if v:FindFirstChild("Fixed") ~= nil then
		ModelWeld(v.Fixed, axle)
	end

	if v:FindFirstChild("Parts") ~= nil then
		ModelWeld(v.Parts, v)
	end

	if v:FindFirstChild("Steer") then
		v:FindFirstChild("Steer"):Destroy()
	end

	local gyro = Instance.new("BodyGyro", v)
	gyro.Name = "Stabilizer"
	if v.Name == "FL" or v.Name == "FR" or v.Name == "F" then
		gyro.D = _Tune.FGyroD
		gyro.MaxTorque = _Tune.FGyroMaxTorque
		gyro.P = _Tune.FGyroP
	else
		gyro.D = _Tune.RGyroD
		gyro.MaxTorque = _Tune.RGyroMaxTorque
		gyro.P = _Tune.RGyroP
	end

	if v.Name == "FL" or v.Name == "FR" or v.Name == "F" then
		local steer = Instance.new("BodyGyro", arm)
		steer.Name = "Steer"
		steer.P = _Tune.SteerP
		steer.D = _Tune.SteerD
		steer.MaxTorque = Vector3.new(0, _Tune.SteerMaxTorque, 0)
		steer.cframe = base.CFrame
	else
		MakeWeld(base, axle, "Weld")
	end

	local AV = Instance.new("BodyAngularVelocity", v)
	AV.Name = "#AV"
	AV.angularvelocity = Vector3.new(0, 0, 0)
	AV.maxTorque = Vector3.new(_Tune.PBrakeForce, 0, _Tune.PBrakeForce)
	AV.P = 1e9
end

for i, v in pairs(script:GetChildren()) do
	if v:IsA("ModuleScript") then
		require(v)
	end
end

wait()
ModelWeld(car.Body, car.AirSetup)

local flipG = Instance.new("BodyGyro", car.DriveSeat)
flipG.Name = "Flip"
flipG.D = 0
flipG.MaxTorque = Vector3.new(0, 0, 0)
flipG.P = 0

wait()

UnAnchor(car)

script.Parent["A-Chassis Interface"].Car.Value = car
for i, v in pairs(script.Parent.Plugins:GetChildren()) do
	for _, a in pairs(v:GetChildren()) do
		if a:IsA("RemoteEvent") or a:IsA("RemoteFunction") then
			a.Parent = car
			for _, b in pairs(a:GetChildren()) do
				if b:IsA("Script") then
					b.Disabled = false
				end
			end
		end
	end
	v.Parent = script.Parent["A-Chassis Interface"]
end
script.Parent.Plugins:Destroy()

car.DriveSeat.ChildAdded:connect(function(child)
	if
		child.Name == "SeatWeld"
		and child:IsA("Weld")
		and game.Players:GetPlayerFromCharacter(child.Part1.Parent) ~= nil
	then
		local p = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
		car.DriveSeat:SetNetworkOwner(p)
		local g = script.Parent["A-Chassis Interface"]:Clone()
		g.Parent = p.PlayerGui
	end
end)
car.DriveSeat.ChildRemoved:connect(function(child)
	if child.Name == "SeatWeld" and child:IsA("Weld") then
		for i, v in pairs(car.DriveSeat:GetChildren()) do
			if v:IsA("Sound") then
				v:Stop()
			end
		end
		if car.DriveSeat:FindFirstChild("Flip") ~= nil then
			car.DriveSeat.Flip.MaxTorque = Vector3.new()
		end
		for i, v in pairs(car.Wheels:GetChildren()) do
			if v:FindFirstChild("#AV") ~= nil then
				if v["#AV"].AngularVelocity.Magnitude > 0 then
					v["#AV"].AngularVelocity = Vector3.new()
					v["#AV"].MaxTorque = Vector3.new()
				end
			end
		end
	end
end)

ver = require(script.Parent.README)
