local y=0 function getMass(m)for m,R in pairs(m:GetChildren())do if R:IsA("\066\097\115\101\080\097\114\116")then y=y+R:GetMass()end getMass(R)end end getMass(car)if y<_Tune.Weight*weightScaling then local m=Vector3.new()local R=Vector3.new()local W=0 local p=0 for y,g in pairs(Drive)do if g.Name=="\070\076"or g.Name=="\070\082"or g.Name=="\070"then m=m+g.CFrame.p W=W+1 else R=R+g.CFrame.p p=p+1 end end m=m/W R=R/p local g=R:Lerp(m,_Tune.WeightDist/100)local Q=Instance.new("\080\097\114\116",car.Body)Q.Name="\035\087\101\105\103\104\116"Q.Anchored=true Q.CanCollide=false Q.BrickColor=BrickColor.new("\082\101\097\108\108\121 \098\108\097\099\107")Q.TopSurface=Enum.SurfaceType.Smooth Q.BottomSurface=Enum.SurfaceType.Smooth if _Tune.WBVisible then Q.Transparency=.75 else Q.Transparency=1 end Q.Size=Vector3.new(_Tune.WeightBSize[1],_Tune.WeightBSize[2],_Tune.WeightBSize[3])Q.CustomPhysicalProperties=PhysicalProperties.new((_Tune.Weight*weightScaling-y)/((Q.Size.x*Q.Size.y)*Q.Size.z),0,0,0,0)Q.CFrame=((car.Body.CarName.Value.VehicleSeat.CFrame-car.Body.CarName.Value.VehicleSeat.Position)+g)*CFrame.new(0,_Tune.CGHeight,0)else warn("\n\t \091\065\067"..(_BuildVersion..("\093\058 \077\097\115\115 \116\111\111 \104\105\103\104 \102\111\114 \115\112\101\099\105\102\105\101\100 \119\101\105\103\104\116\046"..("\n\t    \084\097\114\103\101\116 \077\097\115\115\058\t"..(math.ceil((_Tune.Weight*weightScaling)*100)/100 ..("\n\t    \067\117\114\114\101\110\116 \077\097\115\115\058\t"..(math.ceil(y*100)/100 .."\n\t \082\101\100\117\099\101 \112\097\114\116 \115\105\122\101 \111\114 \097\120\108\101 \100\101\110\115\105\116\121 \116\111 \097\099\104\105\101\118\101 \100\101\115\105\114\101\100 \119\101\105\103\104\116\046")))))))end local m=Instance.new("\066\111\100\121\071\121\114\111",car.Body.CarName.Value.VehicleSeat)m.Name="\070\108\105\112"m.D=0 m.MaxTorque=Vector3.new(0,0,0)m.P=0
--[[Vehicle Weight]]
--Determine Current Mass
local mass = 0

function getMass(p)
	for i, v in pairs(p:GetChildren()) do
		if v:IsA("BasePart") then
			mass = mass + v:GetMass()
		end
		getMass(v)
	end
end
getMass(car)

--Apply Vehicle Weight
if mass < _Tune.Weight * weightScaling then
	--Calculate Weight Distribution
	local centerF = Vector3.new()
	local centerR = Vector3.new()
	local countF = 0
	local countR = 0

	for i, v in pairs(Drive) do
		if v.Name == "FL" or v.Name == "FR" or v.Name == "F" then
			centerF = centerF + v.CFrame.p
			countF = countF + 1
		else
			centerR = centerR + v.CFrame.p
			countR = countR + 1
		end
	end
	centerF = centerF / countF
	centerR = centerR / countR
	local center = centerR:Lerp(centerF, _Tune.WeightDist / 100)

	--Create Weight Brick
	local weightB = Instance.new("Part", car.Body)
	weightB.Name = "#Weight"
	weightB.Anchored = true
	weightB.CanCollide = false
	weightB.BrickColor = BrickColor.new("Really black")
	weightB.TopSurface = Enum.SurfaceType.Smooth
	weightB.BottomSurface = Enum.SurfaceType.Smooth
	if _Tune.WBVisible then
		weightB.Transparency = 0.75
	else
		weightB.Transparency = 1
	end
	weightB.Size = Vector3.new(_Tune.WeightBSize[1], _Tune.WeightBSize[2], _Tune.WeightBSize[3])
	weightB.CustomPhysicalProperties = PhysicalProperties.new(
		((_Tune.Weight * weightScaling) - mass) / (weightB.Size.x * weightB.Size.y * weightB.Size.z),
		0,
		0,
		0,
		0
	)
	weightB.CFrame = (car.Body.CarName.Value.VehicleSeat.CFrame - car.Body.CarName.Value.VehicleSeat.Position + center)
		* CFrame.new(0, _Tune.CGHeight, 0)
else
	--Existing Weight Is Too Massive
	warn(
		"\n\t [AC"
			.. _BuildVersion
			.. "]: Mass too high for specified weight."
			.. "\n\t    Target Mass:\t"
			.. (math.ceil(_Tune.Weight * weightScaling * 100) / 100)
			.. "\n\t    Current Mass:\t"
			.. (math.ceil(mass * 100) / 100)
			.. "\n\t Reduce part size or axle density to achieve desired weight."
	)
end

local flipG = Instance.new("BodyGyro", car.Body.CarName.Value.VehicleSeat)
flipG.Name = "Flip"
flipG.D = 0
flipG.MaxTorque = Vector3.new(0, 0, 0)
flipG.P = 0
