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

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
		for _,a in pairs(v.Parts:GetChildren()) do
			if a:IsA("BasePart") then
				table.insert(WParts, {a,v.CFrame:toObjectSpace(a.CFrame)})
			end
		end
	end
	if v:FindFirstChild("Fixed")~=nil then
		for _,a in pairs(v.Fixed:GetChildren()) do
			if a:IsA("BasePart") then
				table.insert(WParts, {a,v.CFrame:toObjectSpace(a.CFrame)})
			end			
		end
	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,math.rad(-_Tune.FCaster),math.rad(_Tune.FToe))
		else
			v.CFrame = v.CFrame*CFrame.Angles(0,math.rad(_Tune.FCaster),math.rad(-_Tune.FToe))
		end
	else
		v.CFrame = v.CFrame*CFrame.Angles(math.rad(_Tune.RCamber),0,0)
		if v.Name=="RL" then
			v.CFrame = v.CFrame*CFrame.Angles(0,math.rad(-_Tune.RCaster),math.rad(_Tune.RToe))
		else
			v.CFrame = v.CFrame*CFrame.Angles(0,math.rad(_Tune.RCaster),math.rad(-_Tune.RToe))
		end
	end
	
	
	for _,a in pairs(WParts) do
		a[1].CFrame=v.CFrame:toWorldSpace(a[2])
	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
	MakeWeld(car.DriveSeat,base)
	if v.Parent.Name == "RL" or v.Parent.Name == "RR" 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" 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" 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.DriveSeat)

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 v: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)
