function Flip()if(car.DriveSeat.CFrame*CFrame.Angles(math.pi/2,0,0)).lookVector.y>.1 or FlipDB then FlipWait=tick()else if tick()-FlipWait>=3 then FlipDB=true local O=car.DriveSeat.Flip O.maxTorque=Vector3.new(10000,0,10000)O.P=3000 O.D=500 wait(1)O.maxTorque=Vector3.new(0,0,0)O.P=0 O.D=0 FlipDB=false end end end function AWD()if car.DriveSeat.AWD.Value then if _Tune.Config=="\070\087\068"or _Tune.Config=="\065\087\068"then for O,X in pairs(car.Wheels:GetChildren())do if X.Name=="\082\076"or X.Name=="\082\082"or X.Name=="\082"then table.insert(Drive,X)end end end else if _Tune.Config=="\070\087\068"or _Tune.Config=="\065\087\068"then for O,X in pairs(car.Wheels:GetChildren())do if X.Name=="\082\076"or X.Name=="\082\082"or X.Name=="\082"then table.remove(Drive,3)table.remove(Drive,4)end end end end end car.DriveSeat.AWD.Changed:connect(function()AWD()end)AWD()
--[[Flip]]

function Flip()
	--Detect Orientation
	if (car.DriveSeat.CFrame * CFrame.Angles(math.pi / 2, 0, 0)).lookVector.y > 0.1 or FlipDB then
		FlipWait = tick()

		--Apply Flip
	else
		if tick() - FlipWait >= 3 then
			FlipDB = true
			local gyro = car.DriveSeat.Flip
			gyro.maxTorque = Vector3.new(10000, 0, 10000)
			gyro.P = 3000
			gyro.D = 500
			wait(1)
			gyro.maxTorque = Vector3.new(0, 0, 0)
			gyro.P = 0
			gyro.D = 0
			FlipDB = false
		end
	end
end

function AWD()
	if car.DriveSeat.AWD.Value then -- SET AWD
		if _Tune.Config == "FWD" or _Tune.Config == "AWD" then
			for i, v in pairs(car.Wheels:GetChildren()) do
				if v.Name == "RL" or v.Name == "RR" or v.Name == "R" then
					table.insert(Drive, v)
				end
			end
		end
	else --make FWD
		if _Tune.Config == "FWD" or _Tune.Config == "AWD" then
			for i, v in pairs(car.Wheels:GetChildren()) do
				if v.Name == "RL" or v.Name == "RR" or v.Name == "R" then
					table.remove(Drive, 3)
					table.remove(Drive, 4)
				end
			end
		end
	end
end

car.DriveSeat.AWD.Changed:connect(function()
	AWD()
end)

AWD()
