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