uv=script.Parent.CFrame.upVector local t=WeightDistribution local F=t/25 local A=(100-t)/25 local W=math.max(0,A-1)local Q=math.min(F,1)local I=(FL.Position+FR.Position)*W local h=(RL.Position+RR.Position)*Q local g=(W+Q)*2 local Y=Instance.new("\080\097\114\116")Y.Parent=script.Parent.Parent Y.CanCollide=false Y.Position=script.Parent.Position Y.CFrame=CFrame.new((I+h)/g)Y.Position=Y.Position+Vector3.new(.9,.9,.9)*script.Parent.CFrame.upVector Y.Size=Vector3.new(3,2,4)Y.Rotation=script.Parent.Rotation Y.Name="\087\101\105\103\104\116"Y.Anchored=true local y=Instance.new("\080\097\114\116")y.Anchored=true y.Parent=script.Parent.Parent y.CanCollide=false y.Position=script.Parent.Position y.Position=y.Position+Vector3.new(2,2,2)*script.Parent.CFrame.upVector y.Size=Vector3.new(1,.7,.7)*(EngineDisplacement/4000)+Vector3.new(2,1.4,1.4)y.Rotation=script.Parent.Rotation y.Name="\069\110\103\105\110\101"local m=Instance.new("\080\097\114\116")m.Anchored=true m.Parent=script.Parent.Parent m.CanCollide=false m.Position=script.Parent.Position m.Position=m.Position+Vector3.new(2.5,2.5,2.5)*script.Parent.CFrame.upVector m.Size=Vector3.new(2.5,2.5,7)m.Rotation=script.Parent.Rotation m.Name="\070\117\101\108\084\097\110\107"local c=Instance.new("\080\097\114\116")c.Anchored=true c.Parent=script.Parent.Parent c.CanCollide=false c.Position=script.Parent.Position c.Position=c.Position+Vector3.new(3,3,3)*script.Parent.CFrame.upVector c.Size=Vector3.new(2.7,2,2)*(AmountOfGears/7)c.Rotation=script.Parent.Rotation c.Name="\084\114\097\110\115\109\105\115\115\105\111\110"local R=Instance.new("\080\097\114\116")R.Anchored=true R.Parent=script.Parent.Parent R.CanCollide=false R.Position=script.Parent.Position R.Position=R.Position+Vector3.new(3.5,3.5,3.5)*script.Parent.CFrame.upVector R.Size=Vector3.new(2,2,2)R.Rotation=script.Parent.Rotation R.Name="\068\105\102\102\101\114\101\110\116\105\097\108"m.CFrame=CFrame.new((RL.Position+RR.Position)/2)m.CFrame=m.CFrame+Vector3.new(3,3,3)*lv if Drivetrain=="\082\087\068"then R.CFrame=CFrame.new((RL.Position+RR.Position)/2)elseif Drivetrain=="\070\087\068"then R.CFrame=CFrame.new((FL.Position+FR.Position)/2)y.Rotation=y.Rotation+Vector3.new(0,90,0)elseif Drivetrain=="\065\087\068"then R.CFrame=CFrame.new((RL.Position+RR.Position)/2)if TorqueSplit<51 then y.Rotation=y.Rotation+Vector3.new(0,90,0)end end if EngineLocation=="\070\114\111\110\116"then y.CFrame=CFrame.new((FL.Position+FR.Position)/2)y.CFrame=y.CFrame+Vector3.new(2,2,2)*lv y.CFrame=y.CFrame+Vector3.new(1,1,1)*uv c.CFrame=y.CFrame+Vector3.new(-1.5,-1.5,-1.5)*lv elseif EngineLocation=="\077\105\100"then y.CFrame=CFrame.new((RL.Position+RR.Position)/2)y.CFrame=y.CFrame+Vector3.new(2,2,2)*lv y.CFrame=y.CFrame+Vector3.new(1,1,1)*uv c.CFrame=y.CFrame+Vector3.new(1.5,1.5,1.5)*lv elseif EngineLocation=="\082\101\097\114"then y.CFrame=CFrame.new((RL.Position+RR.Position)/2)y.CFrame=y.CFrame+Vector3.new(-2,-2,-2)*lv y.CFrame=y.CFrame+Vector3.new(1,1,1)*uv c.CFrame=y.CFrame+Vector3.new(-1.5,-1.5,-1.5)*lv end rv=script.Parent.CFrame.rightVector


uv = script.Parent.CFrame.upVector

local distribution = WeightDistribution --0-100%, how much of the weight is in the rear, 50 = 50%/50%

local DistA = (distribution/25)
local DistB = ((100-distribution)/25)

local Dist1 = math.max(0,DistB-1)
local Dist2 = math.min(DistA,1)

local DistF = (FL.Position+FR.Position)*Dist1
local DistR = (RL.Position+RR.Position)*Dist2
local DistD = (Dist1+Dist2)*2

local weight = Instance.new("Part")
weight.Parent = script.Parent.Parent
weight.CanCollide = false
weight.Position = script.Parent.Position
weight.CFrame = CFrame.new((DistF+DistR)/DistD)
weight.Position = weight.Position + Vector3.new(0.9,0.9,0.9)*script.Parent.CFrame.upVector
weight.Size = Vector3.new(3, 2, 4)
weight.Rotation = script.Parent.Rotation
weight.Name = "Weight"
weight.Anchored = true

local engine = Instance.new("Part") engine.Anchored = true
engine.Parent = script.Parent.Parent
engine.CanCollide = false
engine.Position = script.Parent.Position
engine.Position = engine.Position + Vector3.new(2,2,2)*script.Parent.CFrame.upVector
engine.Size = (Vector3.new(1, 0.7, 0.7)*(EngineDisplacement/4000))+Vector3.new(2, 1.4, 1.4)
engine.Rotation = script.Parent.Rotation
engine.Name = "Engine"


local fuel = Instance.new("Part") fuel.Anchored = true
fuel.Parent = script.Parent.Parent
fuel.CanCollide = false
fuel.Position = script.Parent.Position
fuel.Position = fuel.Position + Vector3.new(2.5,2.5,2.5)*script.Parent.CFrame.upVector
fuel.Size = Vector3.new(2.5, 2.5, 7)
fuel.Rotation = script.Parent.Rotation
fuel.Name = "FuelTank"


local trans = Instance.new("Part") trans.Anchored = true
trans.Parent = script.Parent.Parent
trans.CanCollide = false
trans.Position = script.Parent.Position
trans.Position = trans.Position + Vector3.new(3,3,3)*script.Parent.CFrame.upVector
trans.Size = Vector3.new(2.7, 2, 2)*(AmountOfGears/7)
trans.Rotation = script.Parent.Rotation
trans.Name = "Transmission"


local diff = Instance.new("Part") diff.Anchored = true
diff.Parent = script.Parent.Parent
diff.CanCollide = false
diff.Position = script.Parent.Position
diff.Position = diff.Position + Vector3.new(3.5,3.5,3.5)*script.Parent.CFrame.upVector
diff.Size = Vector3.new(2, 2, 2)
diff.Rotation = script.Parent.Rotation
diff.Name = "Differential"


fuel.CFrame = CFrame.new(((RL.Position)+(RR.Position))/2)
fuel.CFrame = fuel.CFrame + Vector3.new(3,3,3)*lv

if Drivetrain == "RWD" then
	diff.CFrame = CFrame.new(((RL.Position)+(RR.Position))/2)

elseif Drivetrain == "FWD" then
	diff.CFrame = CFrame.new(((FL.Position)+(FR.Position))/2)
	engine.Rotation = engine.Rotation + Vector3.new(0,90,0)

elseif Drivetrain == "AWD" then
	diff.CFrame = CFrame.new(((RL.Position)+(RR.Position))/2)
	
		if TorqueSplit < 51 then
		engine.Rotation = engine.Rotation + Vector3.new(0,90,0)
		end
end

if EngineLocation == "Front" then
	engine.CFrame = CFrame.new(((FL.Position)+(FR.Position))/2)
	engine.CFrame = engine.CFrame + Vector3.new(2,2,2)*lv
	engine.CFrame = engine.CFrame + Vector3.new(1,1,1)*uv
	trans.CFrame = engine.CFrame + Vector3.new(-1.5,-1.5,-1.5)*lv
	
elseif EngineLocation == "Mid" then
	engine.CFrame = CFrame.new(((RL.Position)+(RR.Position))/2)
	engine.CFrame = engine.CFrame + Vector3.new(2,2,2)*lv	
	engine.CFrame = engine.CFrame + Vector3.new(1,1,1)*uv
	trans.CFrame = engine.CFrame + Vector3.new(1.5,1.5,1.5)*lv
	
elseif EngineLocation == "Rear" then
	engine.CFrame = CFrame.new(((RL.Position)+(RR.Position))/2)
	engine.CFrame = engine.CFrame + Vector3.new(-2,-2,-2)*lv
	engine.CFrame = engine.CFrame + Vector3.new(1,1,1)*uv
	trans.CFrame = engine.CFrame + Vector3.new(-1.5,-1.5,-1.5)*lv
	
end

rv = script.Parent.CFrame.rightVector
