Prompt:
--[=[
	If the brio is not dead, will return the values unpacked from the brio.

	:::info
	Calling this while the brio is already dead will throw a error. Values should
	not be used past the lifetime of the brio, and can be considered invalid.
	:::

	```lua
	local brio = Brio.new("a", 1, 2)
	print(brio:GetValue()) --> "a" 1 2
	brio:Kill()

	print(brio:GetValue()) --> ERROR: Brio is dead
	```

	@return any
]=]

Response:
function Brio:GetValue()
	assert(self._values, "Brio is dead")

	return unpack(self._values, 1, self._values.n)
end


Prompt: -- Decompiled with the Synapse X Luau decompiler.

Response:
local v1 = {};
v1.__index = v1;
function v1.new()
	local v2 = setmetatable({}, v1);
	v2.cameras = require(script:WaitForChild("CameraModule"));
	v2.controls = require(script:WaitForChild("ControlModule"));
	return v2;
end;
function v1.GetCameras(p1)
	return p1.cameras;
end;
function v1.GetControls(p2)
	return p2.controls;
end;
function v1.GetClickToMoveController(p3)
	return p3.controls:GetClickToMoveController();
end;
return v1.new();


Prompt: --[[Drivetrain]]

Response: Tune.Config			= "AWD"		--"FWD" , "RWD" , "AWD"


Prompt: --Returns hit, position, normal, time

Response:
function raycast(model, start, vector, brickFunction)
	local hit, normal, time = raycastRecursive(model, start, vector, brickFunction, vector.unit, dot(start, vector.unit))
	if (dot(normal, vector) > 0) then
		normal = -normal
	end
	return hit, start + time * vector, normal.unit, time
end
function raycastRecursive(model, start, vector, brickFunction, unitVec, startDist)
	if (model.className == "Part") or (model.className == "Seat") or (model.className =="SpawnLocation") then
		local range = model.Size.magnitude / 2
		local dist = dot(model.Position, unitVec) - startDist
		if (dist + range > 0) and (dist - range < vector.magnitude) and ((dist * unitVec + start - model.Position).magnitude < range) and brickFunction(model) then
			local halfSize = model.Size / 2
			if (model.Shape == Enum.PartType.Ball) then
				local time, timeMax = getLineSphereCollide(start, vector, model.Position, halfSize.x)
				if (time < 1) and (time >= 0) then
					return model, (time * vector + start - model.Position), time
				else
					return nil, Vector3.new(0, 0, 0), 1
				end
			elseif (model.Shape == Enum.PartType.Block) then
				local time = 1
				local cf = model.CFrame - model.Position
				local xvec = cf * Vector3.new(1, 0, 0)
				local yvec = cf * Vector3.new(0, 1, 0)
				local zvec = cf * Vector3.new(0, 0, 1)
				local xspd = -dot(xvec, vector)
				local yspd = -dot(yvec, vector)
				local zspd = -dot(zvec, vector)
				local xmin, xmax, ymin, ymax, zmin, zmax = -1
				local dotProd = dot(xvec, start - model.Position)
				if (xspd ~= 0) then
					xmin = (dotProd - halfSize.x) / xspd
					xmax = (dotProd + halfSize.x) / xspd
					if (xmax < xmin) then
						local swap = xmin
						xmin = xmax
						xmax = swap
					end
				else
					if (math.abs(dotProd) < halfSize.x) then
						xmax = 1
						xmin = 0
					else
						return nil, Vector3.new(0, 0, 0), 1
					end
				end
				local dotProd = dot(yvec, start - model.Position)
				if (yspd ~= 0) then
					ymin = (dotProd - halfSize.y) / yspd
					ymax = (dotProd + halfSize.y) / yspd
					if (ymax < ymin) then
						local swap = ymin
						ymin = ymax
						ymax = swap
					end
				else
					if (math.abs(dotProd) < halfSize.y) then
						ymax = 1
						ymin = 0
					else
						return nil, Vector3.new(0, 0, 0), 1
					end
				end
				local dotProd = dot(zvec, start - model.Position)
				if (zspd ~= 0) then
					zmin = (dotProd - halfSize.z) / zspd
					zmax = (dotProd + halfSize.z) / zspd
					if (zmax < zmin) then
						local swap = zmin
						zmin = zmax
						zmax = swap
					end
				else
					if (math.abs(dotProd) < halfSize.z) then
						zmax = 1
						zmin = 0
					else
						return nil, Vector3.new(0, 0, 0), 1
					end
				end
				if (xmin <= ymax) and (xmax >= ymin) and (xmin <= zmax) and (xmax >= zmin) and (zmin <= ymax) and (zmax >= ymin) then
					local normal = xvec
					local min = xmin
					if (ymin > min) then
						min = ymin
						normal = yvec
					end
					if (zmin > min) then
						min = zmin
						normal = zvec
					end
					if (min >= 0) and (min < 1) then
						time = min
					elseif (xmax > 0) and (ymax > 0) and (zmax > 0) and (min < 0) then
						time = 0
						normal = Vector3.new(0, 0, 0)
					end
					return model, normal, time
				else
					return nil, Vector3.new(0, 0, 0), 1
				end
			else	--	Cylinder
				local time = 1
				local cf = model.CFrame - model.Position
				local xvec = cf * Vector3.new(1, 0, 0)
				local xspd = -dot(xvec, vector)
				local xmin, xmax = -1
				local dotProd = dot(xvec, start - model.Position)
				if (xspd ~= 0) then
					xmin = (dotProd - halfSize.x) / xspd
					xmax = (dotProd + halfSize.x) / xspd
					if (xmax < xmin) then
						local swap = xmin
						xmin = xmax
						xmax = swap
					end
				else
					if (math.abs(dotProd) < halfSize.x) then
						xmax = 1
						xmin = 0
					else
						return nil, Vector3.new(0, 0, 0), 1
					end
				end

				local relVec = cf:pointToObjectSpace(vector) * Vector3.new(0, 1, 1)
				local relPos = model.CFrame:pointToObjectSpace(start) * Vector3.new(0, 1, 1)
				local rmin, rmax = getLineSphereCollide(relPos, relVec, Vector3.new(0, 0, 0), halfSize.y)
				if (xmin <= rmax) and (xmax >= rmin) and (rmax > 0) then
					local normal = xvec
					local min = xmin
					if (rmin > min) then
						min = rmin
						normal = cf * (relPos + relVec * min)
					end
					if (min >= 0) and (min < 1) then
						time = min
					elseif (xmax > 0) and (rmax > 0) and (min < 0) then
						time = 0
						normal = Vector3.new(0, 0, 0)
					end
					return model, normal, time
				else
					return nil, Vector3.new(0, 0, 0), 1
				end
				return nil, Vector3.new(0, 0, 0), 1
			end
		end
		return nil, Vector3.new(0, 0, 0), 1
	elseif (model.className=="Model") or (model.className=="Workspace") or (model.className=="Hat") or (model.className == "Tool") then
		local children=model:GetChildren()
		local time=1
		local normal=Vector3.new(0, 0, 0)
		local hit=nil
		for n = 1, #children do
			if children[n]~= nil then
				local newHit, newNormal, newTime = raycastRecursive(children[n], start, vector, brickFunction, unitVec, startDist)
				if (newTime < time) then
					time = newTime
					hit = newHit
					normal = newNormal
				end
			end
		end
		return hit, normal, time
	else
		return nil, Vector3.new(0, 0, 0), 1
	end
end


Prompt:
--[[**
	<description>
	Sets the cached result to the value provided
	</description>

	<parameter name = "value">
	The value
	</parameter>
**--]]

Response:
function DataStore:Set(value, _dontCallOnUpdate)
	self.value = clone(value)
	self:_Update(_dontCallOnUpdate)
end


Prompt: -- Libraries

Response:
local Roact = require(Vendor:WaitForChild('Roact'))
local Maid = require(Libraries:WaitForChild('Maid'))


Prompt: --// Damage Settings

Response:
	BaseDamage = 34; -- Torso Damage
	LimbDamage = 22; -- Arms and Legs
	ArmorDamage = 11; -- How much damage is dealt against armor (Name the armor "Armor")
	HeadDamage = 2000; -- If you set this to 100, there's a chance the player won't die because of the heal script


Prompt: -- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote

Response:
local emoteNames = { wave = false, point = false, dance = true, dance2 = true, dance3 = true, laugh = false, cheer = false}

math.randomseed(tick())

function findExistingAnimationInSet(set, anim)
	if set == nil or anim == nil then
		return 0
	end

	for idx = 1, set.count, 1 do
		if set[idx].anim.AnimationId == anim.AnimationId then
			return idx
		end
	end

	return 0
end

function configureAnimationSet(name, fileList)
	if (animTable[name] ~= nil) then
		for _, connection in pairs(animTable[name].connections) do
			connection:disconnect()
		end
	end
	animTable[name] = {}
	animTable[name].count = 0
	animTable[name].totalWeight = 0
	animTable[name].connections = {}

	local allowCustomAnimations = true

	--local success, msg = pcall(function() allowCustomAnimations = game:GetService("StarterPlayer").AllowCustomAnimations end)
	--if not success then
	--	allowCustomAnimations = true
	--end

	-- check for config values
	local config = script:FindFirstChild(name)
	if (allowCustomAnimations and config ~= nil) then
		table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
		table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))

		local idx = 0
		for _, childPart in pairs(config:GetChildren()) do
			if (childPart:IsA("Animation")) then
				local newWeight = 1
				local weightObject = childPart:FindFirstChild("Weight")
				if (weightObject ~= nil) then
					newWeight = weightObject.Value
				end
				animTable[name].count = animTable[name].count + 1
				idx = animTable[name].count
				animTable[name][idx] = {}
				animTable[name][idx].anim = childPart
				animTable[name][idx].weight = newWeight
				animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
				table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
				table.insert(animTable[name].connections, childPart.ChildAdded:connect(function(property) configureAnimationSet(name, fileList) end))
				table.insert(animTable[name].connections, childPart.ChildRemoved:connect(function(property) configureAnimationSet(name, fileList) end))
			end
		end
	end

	-- fallback to defaults
	if (animTable[name].count <= 0) then
		for idx, anim in pairs(fileList) do
			animTable[name][idx] = {}
			animTable[name][idx].anim = Instance.new("Animation")
			animTable[name][idx].anim.Name = name
			animTable[name][idx].anim.AnimationId = anim.id
			animTable[name][idx].weight = anim.weight
			animTable[name].count = animTable[name].count + 1
			animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
		end
	end

	-- preload anims
	for i, animType in pairs(animTable) do
		for idx = 1, animType.count, 1 do
			if PreloadedAnims[animType[idx].anim.AnimationId] == nil then
				Humanoid:LoadAnimation(animType[idx].anim)
				PreloadedAnims[animType[idx].anim.AnimationId] = true
			end
		end
	end
end


Prompt: --[[ The Module ]]

Response:
--
local VRBaseCamera = require(script.Parent:WaitForChild("VRBaseCamera"))
local VRCamera = setmetatable({}, VRBaseCamera)
VRCamera.__index = VRCamera

function VRCamera.new()
	local self = setmetatable(VRBaseCamera.new(), VRCamera)

	self.lastUpdate = tick()
	self:Reset()

	return self
end

function VRCamera:Reset()
	self.needsReset = true
	self.needsBlackout = true
	self.motionDetTime = 0.0
	self.blackOutTimer = 0
	self.lastCameraResetPosition = nil
	self.stepRotateTimeout = 0.0
end

function VRCamera:Update(timeDelta)
	local camera = workspace.CurrentCamera
	local newCameraCFrame = camera.CFrame
	local newCameraFocus = camera.Focus

	local player = PlayersService.LocalPlayer
	local humanoid = self:GetHumanoid()
	local cameraSubject = camera.CameraSubject

	if self.lastUpdate == nil or timeDelta > 1 then
		self.lastCameraTransform = nil
	end

	self:StepZoom()

	-- update fullscreen effects
	self:UpdateFadeFromBlack(timeDelta)
	self:UpdateEdgeBlur(player, timeDelta)

	local lastSubjPos = self.lastSubjectPosition
	local subjectPosition: Vector3 = self:GetSubjectPosition()

	-- transition from another camera or from spawn
	if self.needsBlackout then
		self:StartFadeFromBlack()

		local dt = math.clamp(timeDelta, 0.0001, 0.1)
		self.blackOutTimer += dt
		if self.blackOutTimer > CAMERA_BLACKOUT_TIME and game:IsLoaded() then
			self.needsBlackout = false
			self.needsReset = true
		end
	end

	if subjectPosition and player and camera then
		newCameraFocus = self:GetVRFocus(subjectPosition, timeDelta)

		if self:IsInFirstPerson() then
			-- update camera CFrame
			newCameraCFrame, newCameraFocus = self:UpdateFirstPersonTransform(
				timeDelta,newCameraCFrame, newCameraFocus, lastSubjPos, subjectPosition)
		else -- 3rd person
			-- update camera CFrame
			newCameraCFrame, newCameraFocus = self:UpdateThirdPersonTransform(
				timeDelta, newCameraCFrame, newCameraFocus, lastSubjPos, subjectPosition)
		end

		self.lastCameraTransform = newCameraCFrame
		self.lastCameraFocus = newCameraFocus
	end

	self.lastUpdate = tick()
	return newCameraCFrame, newCameraFocus
end

function VRCamera:UpdateFirstPersonTransform(timeDelta, newCameraCFrame, newCameraFocus, lastSubjPos, subjectPosition)
	-- transition from TP to FP
	if self.needsReset then
		self:StartFadeFromBlack()
		self.needsReset = false
		self.stepRotateTimeout = 0.25
		self.VRCameraFocusFrozen = true
	end

	-- blur screen edge during movement
	local player = PlayersService.LocalPlayer
	local subjectDelta = lastSubjPos - subjectPosition
	if subjectDelta.magnitude > 0.01 then
		self:StartVREdgeBlur(player)
	end

	-- straight view, not angled down
	local cameraFocusP = newCameraFocus.p
	local cameraLookVector = self:GetCameraLookVector()
	cameraLookVector = Vector3.new(cameraLookVector.X, 0, cameraLookVector.Z).Unit

	if self.stepRotateTimeout > 0 then
		self.stepRotateTimeout -= timeDelta
	end

	-- step rotate in 1st person
	local rotateInput = CameraInput.getRotation()
	local yawDelta = 0
	if self.stepRotateTimeout <= 0.0 and math.abs(rotateInput.X) > 0.03 then
		yawDelta = 0.5
		if rotateInput.X < 0 then
			yawDelta = -0.5
		end
		self.needsReset = true
	end

	local newLookVector = self:CalculateNewLookVectorFromArg(cameraLookVector, Vector2.new(yawDelta, 0))
	newCameraCFrame = CFrame.new(cameraFocusP - (FP_ZOOM * newLookVector), cameraFocusP)

	return newCameraCFrame, newCameraFocus
end

function VRCamera:UpdateThirdPersonTransform(timeDelta, newCameraCFrame, newCameraFocus, lastSubjPos, subjectPosition)
	local zoom = self:GetCameraToSubjectDistance()
	if zoom < 0.5 then
		zoom = 0.5
	end

	if lastSubjPos ~= nil and self.lastCameraFocus ~= nil then
		-- compute delta of subject since last update
		local player = PlayersService.LocalPlayer
		local subjectDelta = lastSubjPos - subjectPosition
		local moveVector = require(player:WaitForChild("PlayerScripts").PlayerModule:WaitForChild("ControlModule")):GetMoveVector()

		-- is the subject still moving?
		local isMoving = subjectDelta.magnitude > 0.01 or moveVector.magnitude > 0.01
		if isMoving then
			self.motionDetTime = 0.1
		end

		self.motionDetTime = self.motionDetTime - timeDelta
		if self.motionDetTime > 0 then
			isMoving = true
		end

		if isMoving and not self.needsReset then
			-- if subject moves keep old camera focus
			newCameraFocus = self.lastCameraFocus

			-- if the focus subject stopped, time to reset the camera
			self.VRCameraFocusFrozen = true
		else
			local subjectMoved = self.lastCameraResetPosition == nil or (subjectPosition - self.lastCameraResetPosition).Magnitude > 1

			-- recenter the camera on teleport
			if (self.VRCameraFocusFrozen and subjectMoved) or self.needsReset then
				VRService:RecenterUserHeadCFrame()

				self.VRCameraFocusFrozen = false
				self.needsReset = false
				self.lastCameraResetPosition = subjectPosition

				self:ResetZoom()
				self:StartFadeFromBlack()

				-- get player facing direction
				local humanoid = self:GetHumanoid()
				local forwardVector = humanoid.Torso and humanoid.Torso.CFrame.lookVector or Vector3.new(1,0,0)
				-- adjust camera height
				local vecToCameraAtHeight = Vector3.new(forwardVector.X, 0, forwardVector.Z)
				local newCameraPos = newCameraFocus.Position - vecToCameraAtHeight * zoom
				-- compute new cframe at height level to subject
				local newFocus = Vector3.new(newCameraFocus.x, newCameraPos.y, newCameraFocus.z)
				local lookAtPos = Vector3.new(newCameraFocus.Position.X, newCameraPos.Y, newCameraFocus.Position.Z)
				newCameraCFrame = CFrame.new(newCameraPos, lookAtPos)
			end
		end
	end

	return newCameraCFrame, newCameraFocus
end

function VRCamera:EnterFirstPerson()
	self.inFirstPerson = true
	self:UpdateMouseBehavior()
end

function VRCamera:LeaveFirstPerson()
	self.inFirstPerson = false
	self.needsReset = true
	self:UpdateMouseBehavior()

	if self.VRBlur then
		self.VRBlur.Visible = false
	end
end

return VRCamera


Prompt:
--[[
	   ___  _____
	  / _ |/ ___/	Avxnturador | Novena
	 / __ / /__
	/_/ |_\___/ 		 LuaInt | Novena

	*I assume you know what you're doing if you're gonna change something here.* ]]

Response:
--

	--[[START]]

script.Parent:WaitForChild("Car")
script.Parent:WaitForChild("IsOn")
script.Parent:WaitForChild("ControlsOpen")
script.Parent:WaitForChild("Values")

	--[[Dependencies]]

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local UserInputService = game:GetService("UserInputService")
local car = script.Parent.Car.Value
local _Tune = require(car["A-Chassis Tune"])
local _text1 = script.Parent.Version:WaitForChild("TextLabel")
_text1.Parent = script.Parent

	--[[Output Scaling Factor]]

local hpScaling = _Tune.WeightScaling * 10
local FBrakeForce = _Tune.BrakeForce * _Tune.BrakeBias--luaint edit
local RBrakeForce = _Tune.BrakeForce * (1 - _Tune.BrakeBias)--luaint edit
local PBrakeForceF = _Tune.PBrakeForce * _Tune.PBrakeBias
local PBrakeForceR = _Tune.PBrakeForce * (1 - _Tune.PBrakeBias)
local EBrakeForce = _Tune.EBrakeForce
local SteerOuter  = _Tune.SteerOuter--luaint edit
local SteerInner  = _Tune.SteerInner--luaint edit
local RSteerOuter = _Tune.RSteerOuter
local RSteerInner = _Tune.RSteerInner

if not workspace:PGSIsEnabled() then
	error("PGS is not enabled: A-Chassis will not work.")
end

	--[[Status Vars]]

local _IsOn = _Tune.AutoStart
if _Tune.AutoStart and (_Tune.Engine or _Tune.Electric) then
	script.Parent.IsOn.Value = true
end

local _GSteerT = 0
local _GSteerC = 0
local _GThrot = 0
local _InThrot = 0
local _IThrot = _Tune.IdleThrottle / 100
local _GBrake = 0
local _InBrake = 0
local _IBrake = 0

local _ClPressing = false
local _PlayerClutch = false
local _Clutch = 0
local _ClutchKick = 0
local _ClutchModulate = 0
local _RPM = 0
local _HP = 0
local _OutTorque = 0
local _CGear = 0
local _PGear = _CGear
local _ShiftUp = false
local _ShiftDn = false
local _Shifting = false
local _spLimit = 0

local _Boost = 0
local _TCount = 0
local _TPsi = 0
local _TBoost = 0
local _SCount = 0
local _SPsi = 0
local _SBoost = 0
local _NH = 0
local _NT = 0
local _EH = 0
local _ET = 0
local _TH = 0
local _TT = 0
local _SH = 0
local _ST = 0
local _BH = 0
local _BT = 0

local _TMode = _Tune.TransModes[1]

local _MSteer = false
local _SteerL = false
local _SteerR = false
local _PBrake = false
local _TCS = _Tune.TCSEnabled
local _TCSActive = false
local _TCSAmt = 0
local _ABS = _Tune.ABSEnabled
local _ABSActive = false

local FlipWait = tick()
local FlipDB = false

local _InControls = false

	--[[Shutdown]]

car.DriveSeat.ChildRemoved:connect(function(child)
	if child.Name == "SeatWeld" and child:IsA("Weld") then
		script.Parent:Destroy()
	end
end)

	--[[Controls]]

local _CTRL = _Tune.Controls
local Controls = Instance.new("Folder", script.Parent)
Controls.Name = "Controls"
for i, v in pairs(_CTRL) do
	local a = Instance.new("StringValue", Controls)
	a.Name = i
	a.Value = v.Name
	a.Changed:connect(function()
		if i == "MouseThrottle" or i == "MouseBrake" then
			if a.Value == "MouseButton1" or a.Value == "MouseButton2" then
				_CTRL[i] = Enum.UserInputType[a.Value]
			else
				_CTRL[i] = Enum.KeyCode[a.Value]
			end
		else
			_CTRL[i] = Enum.KeyCode[a.Value]
		end
	end)
end

	--Deadzone Adjust
local _PPH = _Tune.Peripherals
for i, v in pairs(_PPH) do
	local a = Instance.new("IntValue", Controls)
	a.Name = i
	a.Value = v
	a.Changed:connect(function()
		a.Value = math.min(100, math.max(0, a.Value))
		_PPH[i] = a.Value
	end)
end

	--Input Handler
function DealWithInput(input, IsRobloxFunction)
	if (UserInputService:GetFocusedTextBox() == nil) and not _InControls then --Ignore when UI Focus
			--Shift Down [Manual Transmission]
		if (input.KeyCode == _CTRL["ContlrShiftDown"] or (_MSteer and input.KeyCode == _CTRL["MouseShiftDown"]) or ((not _MSteer) and input.KeyCode == _CTRL["ShiftDown"])) and ((_IsOn and ((_TMode == "Auto" and _CGear <= 1) and _Tune.AutoShiftVers == "New") or _TMode == "Semi") or _TMode == "Manual") and input.UserInputState == Enum.UserInputState.Begin then
			if not _ShiftDn then
				_ShiftDn = true
			end

			--Shift Up [Manual Transmission]
		elseif (input.KeyCode == _CTRL["ContlrShiftUp"] or (_MSteer and input.KeyCode == _CTRL["MouseShiftUp"]) or ((not _MSteer) and input.KeyCode == _CTRL["ShiftUp"])) and ((_IsOn and ((_TMode == "Auto" and _CGear < 1) and _Tune.AutoShiftVers == "New") or _TMode == "Semi") or _TMode == "Manual") and input.UserInputState == Enum.UserInputState.Begin then
			if not _ShiftUp then
				_ShiftUp = true
			end

			--Toggle Clutch
		elseif (input.KeyCode == _CTRL["ContlrClutch"] or (_MSteer and input.KeyCode == _CTRL["MouseClutch"]) or ((not _MSteer) and input.KeyCode == _CTRL["Clutch"])) and _TMode == "Manual" then
			if input.UserInputState == Enum.UserInputState.Begin then
				_ClPressing = true
				_PlayerClutch = true
			elseif input.UserInputState == Enum.UserInputState.End then
				_ClPressing = false
				_PlayerClutch = false
			end

			--Toggle PBrake
		elseif input.KeyCode == _CTRL["ContlrPBrake"] or (_MSteer and input.KeyCode == _CTRL["MousePBrake"]) or ((not _MSteer) and input.KeyCode == _CTRL["PBrake"]) then
			if input.UserInputState == Enum.UserInputState.Begin then
				_PBrake = not _PBrake
			elseif input.UserInputState == Enum.UserInputState.End then
				if car.DriveSeat.Velocity.Magnitude > 5 then
					_PBrake = false
				end
			end

			--Toggle Transmission Mode
		elseif (input.KeyCode == _CTRL["ContlrToggleTMode"] or input.KeyCode == _CTRL["ToggleTransMode"]) and input.UserInputState == Enum.UserInputState.Begin then
			local n = 1
			for i, v in pairs(_Tune.TransModes) do
				if v == _TMode then
					n = i
					break
				end
			end
			n = n + 1
			if n > #_Tune.TransModes then
				n = 1
			end
			_TMode = _Tune.TransModes[n]

			--Throttle
		elseif ((not _MSteer) and (input.KeyCode == _CTRL["Throttle"] or input.KeyCode == _CTRL["Throttle2"])) or ((((_CTRL["MouseThrottle"] == Enum.UserInputType.MouseButton1 or _CTRL["MouseThrottle"] == Enum.UserInputType.MouseButton2) and input.UserInputType == _CTRL["MouseThrottle"]) or input.KeyCode == _CTRL["MouseThrottle"]) and _MSteer) then
			if input.UserInputState == Enum.UserInputState.Begin and _IsOn then
				_IThrot = 1
				car.DriveSeat.Throttle = 1
			else
				car.DriveSeat.Throttle = 0
				_IThrot = _Tune.IdleThrottle / 100
			end

			--Brake
		elseif ((not _MSteer) and (input.KeyCode == _CTRL["Brake"] or input.KeyCode == _CTRL["Brake2"])) or ((((_CTRL["MouseBrake"] == Enum.UserInputType.MouseButton1 or _CTRL["MouseBrake"] == Enum.UserInputType.MouseButton2) and input.UserInputType == _CTRL["MouseBrake"]) or input.KeyCode == _CTRL["MouseBrake"]) and _MSteer) then
			if input.UserInputState == Enum.UserInputState.Begin then
				car.DriveSeat.Throttle = -1
				_IBrake = 1
			else
				car.DriveSeat.Throttle = 0
				_IBrake = 0
			end

			--Steer Left
		elseif (not _MSteer) and (input.KeyCode == _CTRL["SteerLeft"] or input.KeyCode == _CTRL["SteerLeft2"]) then
			if input.UserInputState == Enum.UserInputState.Begin then
				car.DriveSeat.Steer = -1
				_GSteerT = -1
				_SteerL = true
			else
				if _SteerR then
					car.DriveSeat.Steer = 1
					_GSteerT = 1
				else
					_GSteerT = 0
				end
				car.DriveSeat.Steer = 0
				_SteerL = false
			end

			--Steer Right
		elseif (not _MSteer) and (input.KeyCode == _CTRL["SteerRight"] or input.KeyCode == _CTRL["SteerRight2"]) then
			if input.UserInputState == Enum.UserInputState.Begin then
				_GSteerT = 1
				car.DriveSeat.Steer = 1
				_SteerR = true
			else
				if _SteerL then
					car.DriveSeat.Steer = -1
					_GSteerT = -1
				else
					car.DriveSeat.Steer = 0
					_GSteerT = 0
				end
				_SteerR = false
			end

			--Toggle Mouse Controls
		elseif input.KeyCode == _CTRL["ToggleMouseDrive"] then
			if input.UserInputState == Enum.UserInputState.End then
				_MSteer = not _MSteer
				_IThrot = _Tune.IdleThrottle / 100
				_IBrake = 0
				_GSteerT = 0
			end

			--Toggle TCS
		elseif _Tune.TCSEnabled and _IsOn and input.KeyCode == _CTRL["ToggleTCS"] or input.KeyCode == _CTRL["ContlrToggleTCS"] then
			if input.UserInputState == Enum.UserInputState.End then
				_TCS = not _TCS
			end

			--Toggle ABS
		elseif _Tune.ABSEnabled and _IsOn and input.KeyCode == _CTRL["ToggleABS"] or input.KeyCode == _CTRL["ContlrToggleABS"] then
			if input.UserInputState == Enum.UserInputState.End then
				_ABS = not _ABS
			end

		end

			--Variable Controls
		if input.UserInputType.Name:find("Gamepad") then
				--Gamepad Steering
			if input.KeyCode == _CTRL["ContlrSteer"] then
				if input.Position.X >= 0 then
					local cDZone = math.min(.99, _Tune.Peripherals.ControlRDZone / 100)
					if math.abs(input.Position.X) > cDZone then
						_GSteerT = (input.Position.X - cDZone) / (1 - cDZone)
					else
						_GSteerT = 0
					end
				else
					local cDZone = math.min(.99, _Tune.Peripherals.ControlLDZone / 100)
					if math.abs(input.Position.X) > cDZone then
						_GSteerT = (input.Position.X + cDZone) / (1 - cDZone)
					else
						_GSteerT = 0
					end
				end

				--Gamepad Throttle
			elseif input.KeyCode == _CTRL["ContlrThrottle"] then
				if _IsOn then
					_IThrot = math.max(_Tune.IdleThrottle / 100, input.Position.Z)
				else
					_IThrot = _Tune.IdleThrottle / 100
				end

				--Gamepad Brake
			elseif input.KeyCode == _CTRL["ContlrBrake"] then
				_IBrake = input.Position.Z
			end
		end
	else
		_IThrot = _Tune.IdleThrottle / 100
		_GSteerT = 0
		_IBrake = 0
	end
end
UserInputService.InputBegan:connect(DealWithInput)
UserInputService.InputChanged:connect(DealWithInput)
UserInputService.InputEnded:connect(DealWithInput)

	-- Eniiqz' Mobile Support Mod
if UserInputService.TouchEnabled then
	local Buttons = script.Parent:WaitForChild("Buttons")
	local Left = Buttons:WaitForChild("Left")
	local Right = Buttons:WaitForChild("Right")
	local Brake = Buttons:WaitForChild("Brake")
	local Gas = Buttons:WaitForChild("Gas")
	local Downshift = Buttons.Downshift
	local Upshift = Buttons.Upshift
	local Handbrake = Buttons:WaitForChild("Handbrake")
	script.Parent.TextLabel.Visible = true
	local Thread = coroutine.wrap(function()
		while true do
			wait(0.5)
			if _TMode == "Semi" or _TMode == "Manual" then
				Downshift.Visible = true
				Upshift.Visible = true
			else
				Downshift.Visible = false
				Upshift.Visible = false
			end
		end
	end)
	Thread()
	Buttons.Visible = true

	local function LeftTurn(Touch, GPE)
		if Touch.UserInputState == Enum.UserInputState.Begin then
			_GSteerT = -1
			car.DriveSeat.Steer = -1
			_SteerL = true
		else
			if _SteerR then
				car.DriveSeat.Steer = 1
				_GSteerT = 1
			else
				car.DriveSeat.Steer = 0
				_GSteerT = 0
			end
			_SteerL = false
		end
	end
	Left.InputBegan:Connect(LeftTurn)
	Left.InputEnded:Connect(LeftTurn)
	--Left.InputChanged:Connect(LeftTurn)
	script.Parent.TextLabel.Visible = true
	local function RightTurn(Touch, GPE)
		if Touch.UserInputState == Enum.UserInputState.Begin then
			_GSteerT = 1
			car.DriveSeat.Steer = 1
			_SteerR = true
		else
			if _SteerL then
				car.DriveSeat.Steer = -1
				_GSteerT = -1
			else
				car.DriveSeat.Steer = 0
				_GSteerT = 0
			end
			_SteerR = false
		end
	end
	Right.InputBegan:Connect(RightTurn)
	Right.InputEnded:Connect(RightTurn)
	--Right.InputChanged:Connect(RightTurn)

	local function TouchThrottle(input, GPE)
		if input.UserInputState == Enum.UserInputState.Begin and _IsOn then
			car.DriveSeat.Throttle = 1
			_IThrot = 1
		else
			car.DriveSeat.Throttle = 0
			_IThrot = _Tune.IdleThrottle / 100
		end
	end
	Gas.InputBegan:Connect(TouchThrottle)
	Gas.InputEnded:Connect(TouchThrottle)
	--Gas.InputChanged:Connect(TouchThrottle)

	local function TouchBrake(input, GPE)
		if input.UserInputState == Enum.UserInputState.Begin then
			car.DriveSeat.Throttle = -1
			_IBrake = 1
		else

			_IBrake = 0
			car.DriveSeat.Throttle = 0
		end
	end
	Brake.InputBegan:Connect(TouchBrake)
	Brake.InputEnded:Connect(TouchBrake)
	--Brake.InputChanged:Connect(TouchBrake)
	script.Parent.TextLabel.Visible = true
	local function TouchHandbrake(input, GPE)
		if input.UserInputState == Enum.UserInputState.Begin then
			_PBrake = not _PBrake
		elseif input.UserInputState == Enum.UserInputState.End then
			if car.DriveSeat.Velocity.Magnitude > 5 then
				_PBrake = false
			end
		end
	end
	Handbrake.InputBegan:Connect(TouchHandbrake)
	Handbrake.InputEnded:Connect(TouchHandbrake)

	local function TouchDownshift(input, GPE)
		if ((_IsOn and ((_TMode == "Auto" and _CGear <= 1) and _Tune.AutoShiftVers == "New") or _TMode == "Semi") or _TMode == "Manual") and input.UserInputState == Enum.UserInputState.Begin then
			if not _ShiftDn then
				_ShiftDn = true
			end
		end
	end

	Downshift.InputBegan:Connect(TouchDownshift)

	local function TouchUpshift(input, GPE)
		if ((_IsOn and ((_TMode == "Auto" and _CGear < 1) and _Tune.AutoShiftVers == "New") or _TMode == "Semi") or _TMode == "Manual") and input.UserInputState == Enum.UserInputState.Begin then
			if not _ShiftUp then
				_ShiftUp = true
			end
		end
	end
	Upshift.InputBegan:Connect(TouchUpshift)

end -- MOBILE SUPPORT IF STATEMENT
	--[[Drivetrain Initialize]]

local Drive = {}
script.Parent.TextLabel.Visible = true
	--Power Front Wheels
if _Tune.Config == "FWD" or _Tune.Config == "AWD" then
	for i, v in pairs(car.Wheels:GetChildren()) do
		if v.Name == "FL" or v.Name == "FR" or v.Name == "F" then
			table.insert(Drive, v)
		end
	end
end

	--Power Rear Wheels
if _Tune.Config == "RWD" 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

	--Determine Wheel Size
local wDia = 0
for i, v in pairs(Drive) do
	if v.Size.x > wDia then
		wDia = v.Size.x
	end
end

	--Pre-Toggled PBrake
for i, v in pairs(car.Wheels:GetChildren()) do
	if (math.abs(v["#BV"].MotorMaxTorque - PBrakeForceF) < 1) or (math.abs(v["#BV"].MotorMaxTorque - PBrakeForceR) < 1) then
		_PBrake = true
	end
end

	--[[Throttle and Brake Input Smoothening]]

function Inputs(dt)
	local deltaTime = (60 / (1 / dt))
	if _InThrot <= _IThrot then
		_InThrot = math.min(_IThrot, _InThrot + (_Tune.ThrotAccel * deltaTime))
	else
		_InThrot = math.max(_IThrot, _InThrot - (_Tune.ThrotDecel * deltaTime))
	end
	if _InBrake <= _IBrake then
		_InBrake = math.min(_IBrake, _InBrake + (_Tune.BrakeAccel * deltaTime))
	else
		_InBrake = math.max(_IBrake, _InBrake - (_Tune.BrakeDecel * deltaTime))
	end
end

	--[[Steering]]

if _Tune.SteeringType == 'New' then--luaint edit
	SteerOuter = (_Tune.LockToLock * 180) / _Tune.SteerRatio
	SteerInner = math.min(SteerOuter - (SteerOuter * (1 - _Tune.Ackerman)), SteerOuter * 1.2)
end

function Steering(dt)
	local deltaTime = (60 / (1 / dt))
		--Mouse Steer
	if _MSteer then
		local msWidth = math.max(1, mouse.ViewSizeX * _Tune.Peripherals.MSteerWidth / 200)
		local mdZone = _Tune.Peripherals.MSteerDZone / 100
		local mST = ((mouse.X - mouse.ViewSizeX / 2) / msWidth)
		if math.abs(mST) <= mdZone then
			_GSteerT = 0
		else
			_GSteerT = (math.max(math.min((math.abs(mST) - mdZone), (1 - mdZone)), 0) / (1 - mdZone)) ^ _Tune.MSteerExp * (mST / math.abs(mST))
		end
	end

		--Interpolate Steering
	if _GSteerC < _GSteerT then
		if _GSteerC < 0 then
			_GSteerC = math.min(_GSteerT, _GSteerC + (_Tune.ReturnSpeed * deltaTime))
		else
			_GSteerC = math.min(_GSteerT, _GSteerC + (_Tune.SteerSpeed * deltaTime))
		end
	else
		if _GSteerC > 0 then
			_GSteerC = math.max(_GSteerT, _GSteerC - (_Tune.ReturnSpeed * deltaTime))
		else
			_GSteerC = math.max(_GSteerT, _GSteerC - (_Tune.SteerSpeed * deltaTime))
		end
	end

		--Steer Decay Multiplier
	local sDecay = (1 - math.min(car.DriveSeat.Velocity.Magnitude / _Tune.SteerDecay, 1 - (_Tune.MinSteer / 100)))
	local rsDecay = (1 - math.min(car.DriveSeat.Velocity.Magnitude / _Tune.RSteerDecay, 1 - (_Tune.MinSteer / 100)))

		--Apply Steering
	for i, v in pairs(car.Wheels:GetChildren()) do
		if v.Name == "F" then
			v.Arm.Steer.CFrame = car.Wheels.F.Base.CFrame * CFrame.Angles(0, -math.rad(_GSteerC * _Tune.SteerInner * sDecay), 0)
		elseif v.Name == "FL" then
			if _GSteerC >= 0 then
				v.Arm.Steer.CFrame = car.Wheels.FL.Base.CFrame * CFrame.Angles(0, -math.rad(_GSteerC * SteerOuter * sDecay), 0)--luaint edit
			else
				v.Arm.Steer.CFrame = car.Wheels.FL.Base.CFrame * CFrame.Angles(0, -math.rad(_GSteerC * SteerInner * sDecay), 0)--luaint edit
			end
		elseif v.Name == "FR" then
			if _GSteerC >= 0 then
				v.Arm.Steer.CFrame = car.Wheels.FR.Base.CFrame * CFrame.Angles(0, -math.rad(_GSteerC * SteerInner * sDecay), 0)--luaint edit
			else
				v.Arm.Steer.CFrame = car.Wheels.FR.Base.CFrame * CFrame.Angles(0, -math.rad(_GSteerC * SteerOuter * sDecay), 0)--luaint edit
			end
		elseif v.Name == 'R' then
			if _Tune.FWSteer == 'None' then
			elseif _Tune.FWSteer == 'Static' then
				v.Arm.Steer.CFrame = car.Wheels.R.Base.CFrame * CFrame.Angles(0, math.rad(_GSteerC * RSteerInner * rsDecay * math.max(0, 1 - (car.DriveSeat.Velocity.Magnitude / _Tune.RSteerSpeed))), 0)--luaint edit
			elseif _Tune.FWSteer == 'Speed' then
				v.Arm.Steer.CFrame = car.Wheels.R.Base.CFrame * CFrame.Angles(0, -math.rad(_GSteerC * RSteerInner * rsDecay * math.min(1, (car.DriveSeat.Velocity.Magnitude / _Tune.RSteerSpeed))), 0)--luaint edit
			elseif _Tune.FWSteer == 'Both' then
				v.Arm.Steer.CFrame = car.Wheels.R.Base.CFrame * CFrame.Angles(0, math.rad(_GSteerC * RSteerInner * rsDecay * math.max(-1, 1 - (car.DriveSeat.Velocity.Magnitude / _Tune.RSteerSpeed))), 0)--luaint edit
			end
		elseif v.Name == 'RL' then
			if _Tune.FWSteer == 'None' then
			elseif _Tune.FWSteer == 'Static' then
				if _GSteerC >= 0 then
					v.Arm.Steer.CFrame = car.Wheels.RL.Base.CFrame * CFrame.Angles(0, math.rad(_GSteerC * RSteerOuter * rsDecay * math.max(0, 1 - (car.DriveSeat.Velocity.Magnitude / _Tune.RSteerSpeed))), 0)--luaint edit
				else
					v.Arm.Steer.CFrame = car.Wheels.RL.Base.CFrame * CFrame.Angles(0, math.rad(_GSteerC * RSteerInner * rsDecay * math.max(0, 1 - (car.DriveSeat.Velocity.Magnitude / _Tune.RSteerSpeed))), 0)--luaint edit
				end
			elseif _Tune.FWSteer == 'Speed' then
				if _GSteerC >= 0 then
					v.Arm.Steer.CFrame = car.Wheels.RL.Base.CFrame * CFrame.Angles(0, -math.rad(_GSteerC * RSteerOuter * rsDecay * math.min(1, (car.DriveSeat.Velocity.Magnitude / _Tune.RSteerSpeed))), 0)--luaint edit
				else
					v.Arm.Steer.CFrame = car.Wheels.RL.Base.CFrame * CFrame.Angles(0, -math.rad(_GSteerC * RSteerInner * rsDecay * math.min(1, (car.DriveSeat.Velocity.Magnitude / _Tune.RSteerSpeed))), 0)--luaint edit
				end
			elseif _Tune.FWSteer == 'Both' then
				if _GSteerC >= 0 then
					v.Arm.Steer.CFrame = car.Wheels.RL.Base.CFrame * CFrame.Angles(0, math.rad(_GSteerC * RSteerOuter * rsDecay * math.max(-1, 1 - (car.DriveSeat.Velocity.Magnitude / _Tune.RSteerSpeed))), 0)--luaint edit
				else
					v.Arm.Steer.CFrame = car.Wheels.RL.Base.CFrame * CFrame.Angles(0, math.rad(_GSteerC * RSteerInner * rsDecay * math.max(-1, 1 - (car.DriveSeat.Velocity.Magnitude / _Tune.RSteerSpeed))), 0)--luaint edit
				end
			end
		elseif v.Name == 'RR' then
			if _Tune.FWSteer == 'None' then
			elseif _Tune.FWSteer == 'Static' then
				if _GSteerC >= 0 then
					v.Arm.Steer.CFrame = car.Wheels.RR.Base.CFrame * CFrame.Angles(0, math.rad(_GSteerC * RSteerInner * rsDecay * math.max(0, 1 - (car.DriveSeat.Velocity.Magnitude / _Tune.RSteerSpeed))), 0)--luaint edit
				else
					v.Arm.Steer.CFrame = car.Wheels.RR.Base.CFrame * CFrame.Angles(0, math.rad(_GSteerC * RSteerOuter * rsDecay * math.max(0, 1 - (car.DriveSeat.Velocity.Magnitude / _Tune.RSteerSpeed))), 0)--luaint edit
				end
			elseif _Tune.FWSteer == 'Speed' then
				if _GSteerC >= 0 then
					v.Arm.Steer.CFrame = car.Wheels.RR.Base.CFrame * CFrame.Angles(0, -math.rad(_GSteerC * RSteerInner * rsDecay * math.min(1, (car.DriveSeat.Velocity.Magnitude / _Tune.RSteerSpeed))), 0)--luaint edit
				else
					v.Arm.Steer.CFrame = car.Wheels.RR.Base.CFrame * CFrame.Angles(0, -math.rad(_GSteerC * RSteerOuter * rsDecay * math.min(1, (car.DriveSeat.Velocity.Magnitude / _Tune.RSteerSpeed))), 0)--luaint edit
				end
			elseif _Tune.FWSteer == 'Both' then
				if _GSteerC >= 0 then
					v.Arm.Steer.CFrame = car.Wheels.RR.Base.CFrame * CFrame.Angles(0, math.rad(_GSteerC * RSteerInner * rsDecay * math.max(-1, 1 - (car.DriveSeat.Velocity.Magnitude / _Tune.RSteerSpeed))), 0)--luaint edit
				else
					v.Arm.Steer.CFrame = car.Wheels.RR.Base.CFrame * CFrame.Angles(0, math.rad(_GSteerC * RSteerOuter * rsDecay * math.max(-1, 1 - (car.DriveSeat.Velocity.Magnitude / _Tune.RSteerSpeed))), 0)--luaint edit
				end
			end
		end
	end
end

	--[[Engine]]

local fFD = _Tune.FinalDrive * _Tune.FDMult
local fFDr = fFD * 30 / math.pi
local cGrav = workspace.Gravity * _Tune.InclineComp / 32.2
local wDRatio = wDia * math.pi / 60
local cfWRot = CFrame.Angles(math.pi / 2, -math.pi / 2, 0)
local cfYRot = CFrame.Angles(0, math.pi, 0)

	--Electric Only Setup

if not _Tune.Engine and _Tune.Electric then
	_Tune.Redline = _Tune.E_Redline
	_Tune.PeakRPM = _Tune.E_Trans2
	_Tune.Turbochargers = 0
	_Tune.Superchargers = 0
	_Tune.Clutch = false
	_Tune.IdleRPM = 0
	_Tune.ClutchType = "Clutch"
	_Tune.AutoShiftType = "DCT"
	_Tune.ShiftUpTime = 0.1
	_Tune.ShiftDnTime = 0.1
end

	--Aspiration Setup

_TCount = _Tune.Turbochargers
_TPsi = _Tune.T_Boost * _Tune.Turbochargers

_SCount = _Tune.Superchargers
_SPsi = _Tune.S_Boost * _Tune.Superchargers

	--Engine Curve

local HP = _Tune.Horsepower / 100
local HP_T = ((_Tune.Horsepower * ((_TPsi) * (_Tune.T_Efficiency / 10)) / 7.5) / 2) / 100
local HP_S = ((_Tune.Horsepower * ((_SPsi) * (_Tune.S_Efficiency / 10)) / 7.5) / 2) / 100

local Peak = _Tune.PeakRPM / 1000
local Sharpness = _Tune.PeakSharpness
local CurveMult = _Tune.CurveMult
local EQ = _Tune.EqPoint / 1000

function CurveN(RPM)
	RPM = RPM / 1000
	return ((-(RPM - Peak) ^ 2) * math.min(HP / (Peak ^ 2), CurveMult ^ (Peak / HP)) + HP) * (RPM - ((RPM ^ Sharpness) / (Sharpness * Peak ^ (Sharpness - 1))))
end
local PeakCurveN = CurveN(_Tune.PeakRPM)

function CurveT(RPM)
	RPM = RPM / 1000
	return ((-(RPM - Peak) ^ 2) * math.min(HP_T / (Peak ^ 2), CurveMult ^ (Peak / HP_T)) + HP_T) * (RPM - ((RPM ^ Sharpness) / (Sharpness * Peak ^ (Sharpness - 1))))
end
local PeakCurveT = CurveT(_Tune.PeakRPM)

function CurveS(RPM)
	RPM = RPM / 1000
	return ((-(RPM - Peak) ^ 2) * math.min(HP_S / (Peak ^ 2), CurveMult ^ (Peak / HP_S)) + HP_S) * (RPM - ((RPM ^ Sharpness) / (Sharpness * Peak ^ (Sharpness - 1))))
end
local PeakCurveS = CurveS(_Tune.PeakRPM)

	--Electric Curve

local EHP = _Tune.E_Horsepower / 100
local ETQ = _Tune.E_Torque / 100
local ETrans1 = _Tune.E_Trans1 / 1000
local ETrans2 = _Tune.E_Trans2 / 1000
local ELimit = _Tune.E_Redline / 1000

function elecHP(RPM)
	RPM = RPM / 1000
	local retVal = 1e-9
	if RPM <= ETrans1 then
		retVal = ((((RPM / ETrans1) ^ _Tune.EH_FrontMult) / (1 / EHP)) * (RPM / ETrans1)) + ((((RPM / ETrans1) ^ (1 / _Tune.EH_FrontMult)) / (1 / EHP)) * (1 - (RPM / ETrans1)))
	elseif ETrans1 < RPM and RPM < ETrans2 then
		retVal = EHP
	elseif ETrans2 <= RPM then
		retVal = EHP - (((RPM - ETrans2) / (ELimit - ETrans2)) ^ _Tune.EH_EndMult) / (1 / (EHP * (_Tune.EH_EndPercent / 100)))
	else
		error( "\n\t [AC6C]: Drive initialization failed!"
			.."\n\t    An unknown error occured when initializing electric horsepower."
			.."\n\t    Please send a screenshot of this message to Avxnturador."
			.."\n\t    R: "..RPM..", T1: "..ETrans1", T2: "..ETrans2", L: "..ELimit".")
	end
	return retVal
end

function elecTQ(RPM)
	RPM = RPM / 1000
	local retVal = 1e-9
	if RPM < ETrans1 then
		retVal = ETQ
	elseif ETrans1 <= RPM then
		retVal = ETQ - (((RPM - ETrans1) / (ELimit - ETrans1)) ^ _Tune.ET_EndMult) / (1 / (ETQ * (_Tune.ET_EndPercent / 100)))
	else
		error( "\n\t [AC6C]: Drive initialization failed!"
			.."\n\t    An unknown error occured when initializing electric torque."
			.."\n\t    Please send a screenshot of this message to Avxnturador."
			.."\n\t    R: "..RPM..", T1: "..ETrans1", T2: "..ETrans2", L: "..ELimit".")
	end
	return retVal
end

	--Plot Current Naturally Aspirated Engine Horsepower
function GetNCurve(x, gear)
	local hp = (math.max(CurveN(x) / (PeakCurveN / HP), 0)) * 100
	return hp, ((hp * (EQ / x)) * _Tune.Ratios[gear + 2] * fFD * hpScaling) * 1000
end

	--Plot Current Electric Horsepower
function GetECurve(x, gear)
	local hp = (math.max(elecHP(x), 0)) * 100
	local tq = (math.max(elecTQ(x), 0)) * 100
	if gear ~= 0 then
		return hp, math.max(tq * _Tune.Ratios[gear + 2] * fFD * hpScaling, 0)
	else
		return 0, 0
	end
end

	--Plot Current Turbocharger Horsepower
function GetTCurve(x, gear)
	local hp = (math.max(CurveT(x) / (PeakCurveT / HP_T), 0)) * 100
	return hp, ((hp * (EQ / x)) * _Tune.Ratios[gear + 2] * fFD * hpScaling) * 1000
end

	--Plot Current Supercharger Horsepower
function GetSCurve(x, gear)
	local hp = (math.max(CurveS(x) / (PeakCurveS / HP_S), 0)) * 100
	return hp, ((hp * (EQ / x)) * _Tune.Ratios[gear + 2] * fFD * hpScaling) * 1000
end

	--Output Cache
local NCache = {}
local ECache = {}
local TCache = {}
local SCache = {}

for gear, ratio in pairs(_Tune.Ratios) do
	local nhpPlot = {}
	local ehpPlot = {}
	local thpPlot = {}
	local shpPlot = {}
	for rpm = 0, math.ceil((_Tune.Redline + 100) / 100) do
		local ntqPlot = {}
		local etqPlot = {}
		local ttqPlot = {}
		local stqPlot = {}
		if rpm ~= 0 then
			if _Tune.Engine then
				ntqPlot.Horsepower, ntqPlot.Torque = GetNCurve(rpm * 100, gear - 2)
				if _TCount ~= 0 then
					ttqPlot.Horsepower, ttqPlot.Torque = GetTCurve(rpm * 100, gear - 2)
				else
					ttqPlot.Horsepower, ttqPlot.Torque = 0, 0
				end
				if _SCount ~= 0 then
					stqPlot.Horsepower, stqPlot.Torque = GetSCurve(rpm * 100, gear - 2)
				else
					stqPlot.Horsepower, stqPlot.Torque = 0, 0
				end
			else
				ntqPlot.Horsepower, ntqPlot.Torque = 0, 0
				ttqPlot.Horsepower, ttqPlot.Torque = 0, 0
				stqPlot.Horsepower, stqPlot.Torque = 0, 0
			end
			if _Tune.Electric then
				etqPlot.Horsepower, etqPlot.Torque = GetECurve(rpm * 100, gear - 2)
			else
				etqPlot.Horsepower, etqPlot.Torque = 0, 0
			end
		else
			ntqPlot.Horsepower, ntqPlot.Torque = 0, 0
			etqPlot.Horsepower, etqPlot.Torque = 0, 0
			ttqPlot.Horsepower, ttqPlot.Torque = 0, 0
			stqPlot.Horsepower, stqPlot.Torque = 0, 0
		end
		if _Tune.Engine then
			nhp, ntq = GetNCurve((rpm + 1) * 100, gear - 2)
			if _TCount ~= 0 then
				thp, ttq = GetTCurve((rpm + 1) * 100, gear - 2)
			else
				thp, ttq = 0, 0
			end
			if _SCount ~= 0 then
				shp, stq = GetSCurve((rpm + 1) * 100, gear - 2)
			else
				shp, stq = 0, 0
			end
		else
			nhp, ntq = 0, 0
			thp, ttq = 0, 0
			shp, stq = 0, 0
		end
		if _Tune.Electric then
			ehp, etq = GetECurve((rpm + 1) * 100, gear - 2)
		else
			ehp, etq = 0, 0
		end
		ntqPlot.HpSlope, ntqPlot.TqSlope = (nhp - ntqPlot.Horsepower), (ntq - ntqPlot.Torque)
		etqPlot.HpSlope, etqPlot.TqSlope = (ehp - etqPlot.Horsepower), (etq - etqPlot.Torque)
		ttqPlot.HpSlope, ttqPlot.TqSlope = (thp - ttqPlot.Horsepower), (ttq - ttqPlot.Torque)
		stqPlot.HpSlope, stqPlot.TqSlope = (shp - stqPlot.Horsepower), (stq - stqPlot.Torque)
		nhpPlot[rpm] = ntqPlot
		ehpPlot[rpm] = etqPlot
		thpPlot[rpm] = ttqPlot
		shpPlot[rpm] = stqPlot
	end
	table.insert(NCache, nhpPlot)
	table.insert(ECache, ehpPlot)
	table.insert(TCache, thpPlot)
	table.insert(SCache, shpPlot)
end

	--Powertrain
wait()

	--Automatic Transmission
function Auto()
	local maxSpin = 0
	for i, v in pairs(Drive) do
		if v.RotVelocity.Magnitude > maxSpin then
			maxSpin = v.RotVelocity.Magnitude
		end
	end
	if _IsOn then
		if _Tune.AutoShiftVers == "Old" and _CGear == 0 then
			_CGear = 1
			_ClPressing = false
		end
		if _CGear >= 1 then
			if (_CGear == 1 and _InBrake > 0 and car.DriveSeat.Velocity.Magnitude < 5) and _Tune.AutoShiftVers == "Old" then
				_CGear = -1
				_ClPressing = false
			elseif car.DriveSeat.Velocity.Magnitude > 5 then
				if _Tune.AutoShiftMode == "RPM" then
					if _RPM > (_Tune.PeakRPM + _Tune.AutoUpThresh) then
						if not _ShiftUp and not _Shifting then
							_ShiftUp = true
						end
					elseif math.max(math.min(maxSpin * _Tune.Ratios[_CGear + 1] * fFDr, _Tune.Redline + 100), _Tune.IdleRPM) < (_Tune.PeakRPM - _Tune.AutoDownThresh) and _CGear > 1 then
						if not _ShiftDn and not _Shifting then
							_ShiftDn = true
						end
					end
				else
					if car.DriveSeat.Velocity.Magnitude > math.ceil(wDRatio * (_Tune.PeakRPM + _Tune.AutoUpThresh) / _Tune.Ratios[_CGear + 2] / fFD) then
						if not _ShiftUp and not _Shifting then
							_ShiftUp = true
						end
					elseif car.DriveSeat.Velocity.Magnitude < math.ceil(wDRatio * (_Tune.PeakRPM - _Tune.AutoDownThresh) / _Tune.Ratios[_CGear + 1] / fFD) and _CGear > 1 then
						if not _ShiftDn and not _Shifting then
							_ShiftDn = true
						end
					end
				end
			end
		else
			if (_InThrot - (_Tune.IdleThrottle / 100) > 0 and car.DriveSeat.Velocity.Magnitude < 5) and _Tune.AutoShiftVers == "Old" then
				_CGear = 1
				_ClPressing = false
			end
		end
	end
end

function Gear()
	local maxSpin = 0
	for i, v in pairs(Drive) do
		if v.RotVelocity.Magnitude > maxSpin then
			maxSpin = v.RotVelocity.Magnitude
		end
	end
	if _ShiftUp and not _Shifting then
		if (_TMode == "Manual" and not _ClPressing) or (_TMode == "Manual" and _Tune.ClutchRel and (_InThrot - (_Tune.IdleThrottle / 100) > 0)) or _CGear == #_Tune.Ratios - 2 or (_TMode ~= "Manual" and not _IsOn) then
			_ShiftUp = false
			return
		end
		local NextGear = math.min(_CGear + 3, #_Tune.Ratios)
		if _TMode ~= "Manual" then
			_Shifting = true
			if _CGear > 0 then
				if _Tune.AutoShiftType == "DCT" then
					wait(_Tune.ShiftUpTime)
				elseif _Tune.AutoShiftType == "Rev" then
					repeat
						wait()
					until _RPM <= math.max(math.min(maxSpin * _Tune.Ratios[NextGear] * fFDr, _Tune.Redline - _Tune.RevBounce), _Tune.IdleRPM) or not _IsOn or _ShiftDn
				end
			end
		end
		_ShiftUp = false
		_Shifting = false
		if _TMode ~= "Manual" and not _IsOn then
			return
		end
		_CGear = math.min(_CGear + 1, #_Tune.Ratios - 2)
		if _TMode ~= "Manual" or (_TMode == "Manual" and _CGear == 1) and _IsOn then
			_ClPressing = false
		end
	end
	if _ShiftDn and not _Shifting then
		if (_TMode == "Manual" and not _ClPressing) or _CGear == -1 or (_TMode ~= "Manual" and not _IsOn) then
			_ShiftDn = false
			return
		end
		local PrevGear = math.min(_CGear + 1, #_Tune.Ratios)
		if _TMode ~= "Manual" then
			_Shifting = true
			if _CGear > 1 then
				if _Tune.AutoShiftType == "DCT" then
					wait(_Tune.ShiftDnTime)
				elseif _Tune.AutoShiftType == "Rev" then
					repeat
						wait()
					until _RPM >= math.max(math.min(maxSpin * _Tune.Ratios[PrevGear] * fFDr, _Tune.Redline - _Tune.RevBounce), _Tune.IdleRPM) or not _IsOn or _ShiftUp
				end
			end
		end
		_ShiftDn = false
		_Shifting = false
		if _TMode ~= "Manual" and not _IsOn then
			return
		end
		_CGear = math.max(_CGear - 1, -1)
		if _TMode ~= "Manual" or (_TMode == "Manual" and _CGear == -1) and _IsOn then
			_ClPressing = false
		end
	end
end

local _GoalRPM = 0
local tqTCS = 1
local sthrot = 0
local _StallOK = false
local ticc = tick()
	--Apply Power
function Engine(dt)
	local deltaTime = (60 / (1 / dt))
		--Neutral Gear
	if ((_CGear == 0 or _Shifting) and _IsOn) then
		_ClPressing = true
		_Clutch = 1
		_StallOK = false
	end

	local revMin = _Tune.IdleRPM
	local goalMin = _Tune.IdleRPM
	local goalMax = _Tune.Redline
	if _Tune.Stall and _Tune.Clutch then
		revMin = 0
	end

	if _Shifting and _ShiftUp then
		_GThrot = 0
	elseif _Shifting and _ShiftDn then
		_GThrot = (_Tune.ShiftThrot / 100)
	else
		if (_Tune.AutoShiftVers == "Old" and _CGear == -1 and _TMode == "Auto") then
			_GThrot = _InBrake
		else
			_GThrot = _InThrot
		end
	end

	if (_Tune.AutoShiftVers == "Old" and _CGear == -1 and _TMode == "Auto") then
		_GBrake = _InThrot - (_Tune.IdleThrottle / 100)
	else
		_GBrake = _InBrake
	end

	if not _IsOn then
		ticc = tick()
		revMin = 0
		goalMin = 0
		_GThrot = _Tune.IdleThrottle / 100
		if _TMode ~= "Manual" then
			_CGear = 0
			_ClPressing = true
			_Clutch = 1
		end
	end

	if ((_ClPressing and _CGear == 0) or (_PlayerClutch and _CGear ~= 0)) and _Tune.NeutralLimit then
		if (_CGear == 0 and not _Tune.LimitClutch) or _Tune.LimitClutch then
			goalMax = _Tune.NeutralRevRPM
		end
	end

		--Determine RPM
	local maxSpin = 0
	local maxCount = 0
	local revThrot = _GThrot
	for i, v in pairs(Drive) do
		maxSpin = maxSpin + v.RotVelocity.Magnitude
		maxCount = maxCount + 1
	end
	maxSpin = maxSpin / maxCount

	if _GoalRPM > goalMax + 100 then
		revThrot = _Tune.IdleThrottle / 100
	end

	if _Tune.Engine or _Tune.Electric then
		_GoalRPM = math.clamp((_RPM - _Tune.RevDecay * deltaTime) + ((_Tune.RevDecay + _Tune.RevAccel) * revThrot * deltaTime), goalMin, _Tune.Redline + 100)
	end

	if _GoalRPM > _Tune.Redline then
		if _CGear < #_Tune.Ratios - 2 then
			_GoalRPM = _GoalRPM - _Tune.RevBounce
		else
			_GoalRPM = _GoalRPM - _Tune.RevBounce * .5
		end
	end

	local _WheelRPM = maxSpin * _Tune.Ratios[_CGear + 2] * fFDr

	if _Tune.Clutch then
		if script.Parent.Values.AutoClutch.Value and _IsOn then
			if _Tune.ClutchType == "Clutch" then
				if _ClPressing then
					_ClutchKick = 1
				end
				_ClutchKick = _ClutchKick * (_Tune.ClutchEngage / 100)
				local ClRPMInfluence = math.max((_RPM - _Tune.IdleRPM) * _Tune.ClutchRPMMult / (_Tune.Redline - _Tune.IdleRPM), 0)
				if _Tune.ClutchMode == "New" then
					ClRPMInfluence = 0
				end
				_ClutchModulate = math.min(((((script.Parent.Values.Velocity.Value.Magnitude / _Tune.SpeedEngage) / math.abs(_CGear)) + ClRPMInfluence) - _ClutchKick), 1)
			elseif _Tune.ClutchType == "CVT" or (_Tune.ClutchType == "TorqueConverter" and _Tune.TQLock) then
				if (_GThrot - (_Tune.IdleThrottle / 100) == 0 and script.Parent.Values.Velocity.Value.Magnitude < _Tune.SpeedEngage) or (_GThrot - (_Tune.IdleThrottle / 100) ~= 0 and (_RPM < _Tune.RPMEngage and _WheelRPM < _Tune.RPMEngage)) then
					_ClutchModulate = math.min(_ClutchModulate * (_Tune.ClutchEngage / 100), 1)
				else
					_ClutchModulate = math.min(_ClutchModulate * (_Tune.ClutchEngage / 100) + (1 - (_Tune.ClutchEngage / 100)), 1)
				end
			elseif _Tune.ClutchType == "TorqueConverter" and not _Tune.TQLock then
				_ClutchModulate = math.min((_RPM / _Tune.Redline) * 0.7, 1)
			end
			if not _ClPressing then
				_Clutch = math.min(1 - _ClutchModulate, 1)
			else
				_Clutch = 1
			end
			_StallOK = (_Clutch <= 0.01) or _StallOK
		else
			_StallOK = _Tune.Stall
			_Clutch = script.Parent.Values.Clutch.Value
		end
	else
		_StallOK = false
		if not _ClPressing and not _Shifting then
			_Clutch = 0
		else
			_Clutch = 1
		end
	end

	local aRPM = math.max(math.min((_GoalRPM * _Clutch) + (_WheelRPM * (1 - _Clutch)), _Tune.Redline + 100), revMin)
	local clutchP = math.min(math.abs(aRPM - _RPM) / (_Tune.Flywheel * deltaTime), .9)
	if _ClPressing then
		clutchP = 0
	end
	_RPM = _RPM * clutchP  +  aRPM * (1 - clutchP)

	if _RPM <= (_Tune.IdleRPM / 4) and _StallOK and (tick() - ticc >= 0.2) then
		script.Parent.IsOn.Value = not _Tune.Stall
	end

		--Rev Limiter
	_spLimit = (_Tune.Redline + 100) / (fFDr * _Tune.Ratios[_CGear + 2])
	if _RPM > _Tune.Redline then
		if _CGear < #_Tune.Ratios - 2 then
			_RPM = _RPM - _Tune.RevBounce
		else
			_RPM = _RPM - _Tune.RevBounce * .5
		end
	end

		--Aspiration
	local TPsi = _TPsi / _TCount

	local _BThrot = _GThrot

	if _Tune.Engine then
		if _TCount ~= 0 then
			_TBoost = _TBoost + ((((((_HP * (_BThrot * 1.2) / _Tune.Horsepower) / 8) - (((_TBoost / TPsi * (TPsi / 15))))) * ((8 / (_Tune.T_Size / (deltaTime))) * 2)) / TPsi) * 15)
			if _TBoost < 0.05 then
				_TBoost = 0.05
			elseif _TBoost > 2 then
				_TBoost = 2
			end
		else
			_TBoost = 0
		end
		if _SCount ~= 0 then
			if _BThrot > sthrot then
				sthrot = math.min(_BThrot, sthrot + _Tune.S_Sensitivity * deltaTime)
			elseif _BThrot < sthrot then
				sthrot = math.max(_BThrot, sthrot - _Tune.S_Sensitivity * deltaTime)
			end
			_SBoost = (_RPM / _Tune.Redline) * (.5 + (1.5 * sthrot))
		else
			_SBoost = 0
		end
	else
		_TBoost = 0
		_SBoost = 0
	end

		--Torque calculations
	if _Tune.Engine then
		local cTq = NCache[_CGear + 2][math.floor(math.min(_Tune.Redline, math.max(0, _RPM)) / 100)]
		_NH = cTq.Horsepower + (cTq.HpSlope * (((_RPM - math.floor(_RPM / 100)) / 100) % 1))
		_NT = cTq.Torque + (cTq.TqSlope * (((_RPM - math.floor(_RPM / 100)) / 100) % 1))
		if _TCount ~= 0 then
			local tTq = TCache[_CGear + 2][math.floor(math.min(_Tune.Redline, math.max(0, _RPM)) / 100)]
			_TH = (tTq.Horsepower + (tTq.HpSlope * (((_RPM - math.floor(_RPM / 100)) / 100) % 1))) * (_TBoost / 2)
			_TT = (tTq.Torque + (tTq.TqSlope * (((_RPM - math.floor(_RPM / 100)) / 100) % 1))) * (_TBoost / 2)
		else
			_TH, _TT = 0, 0
		end
		if _SCount ~= 0 then
			local sTq = SCache[_CGear + 2][math.floor(math.min(_Tune.Redline, math.max(0, _RPM)) / 100)]
			_SH = (sTq.Horsepower + (sTq.HpSlope * (((_RPM - math.floor(_RPM / 100)) / 100) % 1))) * (_SBoost / 2)
			_ST = (sTq.Torque + (sTq.TqSlope * (((_RPM - math.floor(_RPM / 100)) / 100) % 1))) * (_SBoost / 2)
		else
			_SH, _ST = 0, 0
		end
		_BH = _TH + _SH
		_BT = _TT + _ST
	else
		_NH, _NT = 0, 0
		_TH, _TT = 0, 0
		_SH, _ST = 0, 0
		_BH, _BT = 0, 0
	end

	if _Tune.Electric and _CGear ~= 0 then
		local eTq = ECache[_CGear + 2][math.floor(math.min(_Tune.Redline, math.max(100, _RPM)) / 100)]
		_EH = eTq.Horsepower + (eTq.HpSlope * (((_RPM - math.floor(_RPM / 100)) / 100) % 1))
		_ET = eTq.Torque + (eTq.TqSlope * (((_RPM - math.floor(_RPM / 100)) / 100) % 1))
	else
		_EH, _ET = 0, 0
	end

	_HP = _NH + _BH + _EH
	_OutTorque = _NT + _BT + _ET

	local iComp = (car.DriveSeat.CFrame.lookVector.y) * cGrav
	if _CGear == -1 then
		iComp = -iComp
	end
	_OutTorque = _OutTorque * math.max(1, (1 + iComp))

		--Average Rotational Speed Calculation
	local fwspeed = 0
	local fwcount = 0
	local rwspeed = 0
	local rwcount = 0

	for i, v in pairs(car.Wheels:GetChildren()) do
		if v.Name == "FL" or v.Name == "FR" or v.Name == "F" then
			fwspeed = fwspeed + v.RotVelocity.Magnitude
			fwcount = fwcount + 1
		elseif v.Name == "RL" or v.Name == "RR" or v.Name == "R" then
			rwspeed = rwspeed + v.RotVelocity.Magnitude
			rwcount = rwcount + 1
		end
	end
	fwspeed = fwspeed / fwcount
	rwspeed = rwspeed / rwcount
	local cwspeed = (fwspeed + rwspeed) / 2

		--Update Wheels
	for i, v in pairs(car.Wheels:GetChildren()) do
			--Reference Wheel Orientation
		local Ref = (CFrame.new(v.Position - ((v.Arm.CFrame * cfWRot).lookVector), v.Position) * cfYRot).lookVector
		local aRef = 1
		local diffMult = 1
		local RRdiffMult = 1
		local RLdiffMult = 1
		local FRdiffMult = 1
		local FLdiffMult = 1
		if v.Name == "FL" or v.Name == "RL" then
			aRef = -1
		end

			--Differential/Torque-Vectoring
		if _Tune.DifferentialType == 'Old' then
			if v.Name == "FL" or v.Name == "FR" then
				diffMult = math.max(0, math.min(1, 1 + ((((v.RotVelocity.Magnitude - fwspeed) / fwspeed) / (math.max(_Tune.FDiffSlipThres, 1) / 100)) * ((_Tune.FDiffLockThres - 50) / 50))))
				if _Tune.Config == "AWD" then
					diffMult = math.max(0, math.min(1, diffMult * (1 + ((((fwspeed - cwspeed) / cwspeed) / (math.max(_Tune.CDiffSlipThres, 1) / 100)) * ((_Tune.CDiffLockThres - 50) / 50)))))
				end
			elseif v.Name == "RL" or v.Name == "RR" then
				diffMult = math.max(0, math.min(1, 1 + ((((v.RotVelocity.Magnitude - rwspeed) / rwspeed) / (math.max(_Tune.RDiffSlipThres, 1) / 100)) * ((_Tune.RDiffLockThres - 50) / 50))))
				if _Tune.Config == "AWD" then
					diffMult = math.max(0, math.min(1, diffMult * (1 + ((((rwspeed - cwspeed) / cwspeed) / (math.max(_Tune.CDiffSlipThres, 1) / 100)) * ((_Tune.CDiffLockThres - 50) / 50)))))
				end
			end
		else
			if v.Name == "FR" then
				local avg = ((v.RotVelocity.Magnitude / car.Wheels.FL.RotVelocity.Magnitude) - 1) * (_Tune.FDiffPreload / 10)
				FRdiffMult = math.ceil(math.max(0, math.min(2, 1 - ( ((_Tune.FDiffPower / 100) * avg * _GThrot) + ((_Tune.FDiffCoast / 100) * avg * (1 - _GThrot))))) * 100) / 100
				FLdiffMult = 2 - FRdiffMult
			elseif v.Name == "FL" then
				local avg = ((v.RotVelocity.Magnitude / car.Wheels.FR.RotVelocity.Magnitude) - 1) * (_Tune.FDiffPreload / 10)
				FLdiffMult = math.ceil(math.max(0, math.min(2, 1 - ( ((_Tune.FDiffPower / 100) * avg * _GThrot) + ((_Tune.FDiffCoast / 100) * avg * (1 - _GThrot))))) * 100) / 100
				FRdiffMult = 2 - FLdiffMult
			elseif v.Name == "RR" then
				local avg = ((v.RotVelocity.Magnitude / car.Wheels.RL.RotVelocity.Magnitude) - 1) * (_Tune.RDiffPreload / 10)
				RRdiffMult = math.ceil(math.max(0, math.min(2, 1 - ( ((_Tune.RDiffPower / 100) * avg * _GThrot) + ((_Tune.RDiffCoast / 100) * avg * (1 - _GThrot))))) * 100) / 100
				RLdiffMult = 2 - RRdiffMult
			elseif v.Name == "RL" then
				local avg = ((v.RotVelocity.Magnitude / car.Wheels.RR.RotVelocity.Magnitude) - 1) * (_Tune.RDiffPreload / 10)
				RLdiffMult = math.ceil(math.max(0, math.min(2, 1 - ( ((_Tune.RDiffPower / 100) * avg * _GThrot) + ((_Tune.RDiffCoast / 100) * avg * (1 - _GThrot))))) * 100) / 100
				RRdiffMult = 2 - RLdiffMult
			end
		end

		_TCSActive = false
		_ABSActive = false
			--Output

			--Apply Power
		local on = 1
		if not script.Parent.IsOn.Value then
			on = 0
		end
		local throt = _GThrot
		local brake = _GBrake
		local clutch = 1
		if _ClPressing then
			clutch = 0
		end
		local tq = _OutTorque

			--Apply ABS
		local tqABS = 1
		if _ABS and brake > 0 and math.abs(v.RotVelocity.Magnitude * (v.Size.x / 2) - v.Velocity.Magnitude) - _Tune.ABSThreshold > 0 then
			tqABS = 0
		end
		_ABSActive = (tqABS < 1)

		local PBrakeV = 0
		if _PBrake == true then
			PBrakeV = 1
		else
			PBrakeV = 0
		end

		local driven = false
		for _, a in pairs(Drive) do
			if a == v then
				driven = true
			end
		end
		if driven then
				--Apply AWD Vectoring
			if _Tune.Config == "AWD" then
				local bias = (_Tune.TorqueVector + 1) / 2
				if string.find(v.Name, "F") then
					tq = tq * (1 - bias)
				elseif string.find(v.Name, "R") then
					tq = tq * bias
				end
			end

				--Apply TCS
			tqTCS = 1
			if _TCS and throt > 0 then
				tqTCS = 1 - (math.min(math.max(0, math.abs(v.RotVelocity.Magnitude * (v.Size.x / 2) - v.Velocity.Magnitude) - _Tune.TCSThreshold) / _Tune.TCSGradient, 1) * (1 - (_Tune.TCSLimit / 100)))
			end
			if tqTCS < 1 then
				_TCSAmt = tqTCS
				_TCSActive = true
			end

				--Update Forces
			local dir = 1
			if _CGear == -1 then
				dir = -1
			end--luaint edit

			if _Tune.ClutchKick and car.DriveSeat.Velocity.Magnitude < _Tune.KickSpeedThreshold and _RPM > _Tune.Redline - _Tune.KickRPMThreshold and v["#BV"].MotorMaxTorque < 1 then
				tq = (tq * _Tune.KickMult)
			end

			local tqOUT = tq * (60 / workspace:GetRealPhysicsFPS()) * (1 + (v.RotVelocity.Magnitude / (120 - workspace:GetRealPhysicsFPS())) ^ (1.15 + (.07 * (1 - (60 / workspace:GetRealPhysicsFPS()))))) * throt * tqTCS * on * clutch

			if v.Name == 'RR' then
				v["#AV"].MotorMaxTorque = tqOUT * RRdiffMult * diffMult
			elseif v.Name == 'RL' then
				v["#AV"].MotorMaxTorque = tqOUT * RLdiffMult * diffMult
			elseif v.Name == 'FR' then
				v["#AV"].MotorMaxTorque = tqOUT * FRdiffMult * diffMult
			elseif v.Name == 'FL' then
				v["#AV"].MotorMaxTorque = tqOUT * FLdiffMult * diffMult
			else
				v["#AV"].MotorMaxTorque = tqOUT * diffMult
			end
			v["#AV"].AngularVelocity = _spLimit * dir

			if string.find(v.Name, "F") then
				v["#BV"].MotorMaxTorque = (FBrakeForce * (60 / workspace:GetRealPhysicsFPS()) * brake * tqABS) + (EBrakeForce * ((1 - throt) * (_RPM / _Tune.Redline))) + (PBrakeForceF * PBrakeV)
			else
				v["#BV"].MotorMaxTorque = (RBrakeForce * (60 / workspace:GetRealPhysicsFPS()) * brake * tqABS) + (EBrakeForce * ((1 - throt) * (_RPM / _Tune.Redline))) + (PBrakeForceR * PBrakeV)
			end
		else--luaint edit
			v["#AV"].MotorMaxTorque = 0
			v["#AV"].AngularVelocity = 0
			if string.find(v.Name, "F") then
				v["#BV"].MotorMaxTorque = (FBrakeForce * (60 / workspace:GetRealPhysicsFPS()) * brake * tqABS) + (PBrakeForceF * PBrakeV)
			else
				v["#BV"].MotorMaxTorque = (RBrakeForce * (60 / workspace:GetRealPhysicsFPS()) * brake * tqABS) + (PBrakeForceR * PBrakeV)
			end
		end
	end
end

	--[[Flip]]

function Flip()
		--Detect Orientation
	if (car.DriveSeat.CFrame * CFrame.Angles(math.pi / 2, 0, 0)).lookVector.y > .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

	--[[Run]]

	--Print Version
local ver = require(car["A-Chassis Tune"].README)
print("Novena: AC6C Loaded - Version "..ver..", Update "..script.Parent.Version.Value)

	--Runtime Loops

	-- ~60 c/s
game["Run Service"].Heartbeat:connect(function(dt)
		--Update Internal Values
	_IsOn = script.Parent.IsOn.Value
	_InControls = script.Parent.ControlsOpen.Value

		--Inputs
	Inputs(dt)

		--Steering
	Steering(dt)

		--Gear
	Gear()

		--Power
	Engine(dt)

		--Update External Values
	script.Parent.Values.Gear.Value = _CGear
	script.Parent.Values.RPM.Value = _RPM
	script.Parent.Values.Boost.Value = ((_TBoost / 2) * _TPsi) + ((_SBoost / 2) * _SPsi)
	script.Parent.Values.BoostTurbo.Value = (_TBoost / 2) * _TPsi
	script.Parent.Values.BoostSuper.Value = (_SBoost / 2) * _SPsi
	script.Parent.Values.HpNatural.Value = _NH
	script.Parent.Values.HpElectric.Value = _EH
	script.Parent.Values.HpTurbo.Value = _TH
	script.Parent.Values.HpSuper.Value = _SH
	script.Parent.Values.HpBoosted.Value = _BH
	script.Parent.Values.Horsepower.Value = _HP
	script.Parent.Values.TqNatural.Value = _NT / _Tune.Ratios[_CGear + 2] / fFD / hpScaling
	script.Parent.Values.TqElectric.Value = _ET / _Tune.Ratios[_CGear + 2] / fFD / hpScaling
	script.Parent.Values.TqTurbo.Value = _TT / _Tune.Ratios[_CGear + 2] / fFD / hpScaling
	script.Parent.Values.TqSuper.Value = _ST / _Tune.Ratios[_CGear + 2] / fFD / hpScaling
	script.Parent.Values.TqBoosted.Value = script.Parent.Values.TqTurbo.Value + script.Parent.Values.TqSuper.Value
	script.Parent.Values.Torque.Value = script.Parent.Values.TqNatural.Value + script.Parent.Values.TqElectric.Value + script.Parent.Values.TqBoosted.Value
	script.Parent.Values.TransmissionMode.Value = _TMode
	script.Parent.Values.Throttle.Value = _GThrot
	script.Parent.Values.Brake.Value = _GBrake
	if script.Parent.Values.AutoClutch.Value then
		script.Parent.Values.Clutch.Value = _Clutch
	end
	script.Parent.Values.SteerC.Value = _GSteerC
	script.Parent.Values.SteerT.Value = _GSteerT
	script.Parent.Values.PBrake.Value = _PBrake
	script.Parent.Values.TCS.Value = _TCS
	script.Parent.Values.TCSActive.Value = _TCSActive
	script.Parent.Values.TCSAmt.Value = 1 - _TCSAmt
	script.Parent.Values.ABS.Value = _ABS
	script.Parent.Values.ABSActive.Value = _ABSActive
	script.Parent.Values.MouseSteerOn.Value = _MSteer
	script.Parent.Values.Velocity.Value = car.DriveSeat.Velocity
end)

	--15 c/s
while wait(.0667) do
		--Automatic Transmission
	if _TMode == "Auto" then
		Auto()
	end

		--Flip
	if _Tune.AutoFlip then
		Flip()
	end
end


Prompt: --| Service |--

Response:
local Players = game:GetService("Players")
local Replicated = game:GetService("ReplicatedStorage")
local Debris = game:GetService("Debris")


Prompt:
--[[for _,v in pairs(TaggedHumanoids) do
	if v and v.Health > 0 then
		UntagHumanoid(v)
		TagHumanoid(v, Creator)
		v:TakeDamage(Properties.LinkDamage * Total) --Let em' have it!!
	end
end]]

Response:
for i=1,#Events,1 do
	if Events[i] then
		Events[i]:Disconnect()
	end
end

for i=1, #Queue, 1 do
	if Queue[i] and Queue[i].Health > 0 then
		UntagHumanoid(Queue[i])
		TagHumanoid(Queue[i], Creator)
		Queue[i]:TakeDamage(Properties.LinkDamage * Total) --Let em' have it!!
		if Queue[i].Health <= 0 then -- Make em disappear!
			for _,v in pairs(GetDescendants(Queue[i].Parent)) do
				pcall(function()
					v.Transparency = 1
				end)
				pcall(function()
					v.Anchored = true
					Deletables[#Deletables+1] = v
					v.Parent = workspace
					v.CanCollide = false
				end)
			end
		end
		pcall(function()
			SparkleQueue[i].Enabled = false
			SparkleQueue[i].Speed = NumberRange.new(10, 20)
			SparkleQueue[i]:Emit(75)
		end)
		pcall(function()
			Sounds[i]:Play()
		end)
		pcall(function()
			AttachQueue[i]["Constellation_Beam"].Enabled = false
		end)
		wait(.25)
	end
end


Prompt:
--//
-- Confetti Cannon by Richard, Onogork 2018.
--//
-- Services.

Response:
local RunService = game:GetService('RunService')
local svcWorkspace = game:GetService("Workspace");
local Camera = svcWorkspace.CurrentCamera;


Prompt:
-- simple if statements, decides where the Tool will spawn
-- depending on the generated number.

Response:
if BlockPosition == 1 then
	Block.CFrame = Pos1
end

if BlockPosition == 2 then
	Block.CFrame = Pos2
end


Prompt: -- The argument must be an integer:

Response:
function fix(num)
	num = tostring(num)
	num = (num:reverse())
	local newNum = ""
	for i = 1,#num do
		if ((i%3) == 0) then	-- Modulo trick to determine if a number is divisible by 3
			newNum = (newNum .. num:sub(i,i) .. ",")
		else
			newNum = (newNum .. num:sub(i,i))
		end
	end
	newNum = newNum:reverse()
	if (newNum:sub(1,1) == ",") then
		newNum = newNum:sub(2)	-- Quick-fix to correct a mistake in the loop above
	end
	return newNum	-- Returns a string, NOT a number!
end

function count()
	if (active) then
		awaiting = (awaiting+1)
		return
	end
	active = true
	wait()	-- When using 'DescendantRemoving,' the brick removing isn't always gone by the time the function is called, so this gives it some time to be removed
	baseParts = {}	-- Clear table
	local function scan(parent)
		for _,v in pairs(parent:GetChildren()) do	-- Easiest way to get all parts is to quickly scan through with loops
			if (v:IsA("BasePart")) then
				table.insert(baseParts,v)
			end
			if (((#baseParts%1000) == 0) and (#baseParts ~= 0)) then	-- Add in a quick wait every 1k bricks to stop an unneccessary lag-attack
				wait()
			end
			scan(v)
		end
	end
	scan(game.Workspace)
	local n = #baseParts
	script.Parent.Count.Text = (fix(n) .. (n == 1 and " Brick" or " Bricks"))	-- Not many people realize what you can do with 'and' and 'or'
	for i = 1,awaiting do
		count()
	end
	awaiting = 0
	active = false
end

function setup()	-- Yes, I add pointless functions to capture events. It feels more organized
	count()
	game.Workspace.DescendantAdded:connect(count)
	game.Workspace.DescendantRemoving:connect(count)
end

setup()


Prompt:
-- int rd_int_be(string src, int s, int e)
-- @src - Source binary string
-- @s - Start index of a big endian integer
-- @e - End index of the integer

Response: local function rd_int_be(src, s, e) return rd_int_basic(src, e - 1, s, -1) end


Prompt: -- Roblox character sound script

Response:
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local SOUND_DATA = {
	Climbing = {
		SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3",
		Looped = true,
	},
	Died = {
		SoundId = "rbxasset://sounds/uuhhh.mp3",
	},
	FreeFalling = {
		SoundId = "rbxasset://sounds/action_falling.mp3",
		Looped = true,
	},
	GettingUp = {
		SoundId = "rbxasset://sounds/action_get_up.mp3",
	},
	Jumping = {
		SoundId = "rbxasset://sounds/action_jump.mp3",
	},
	Landing = {
		SoundId = "rbxasset://sounds/action_jump_land.mp3",
	},
	Running = {
		SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3",
		Looped = true,
		Pitch = 1.85,
	},
	Splash = {
		SoundId = "rbxasset://sounds/impact_water.mp3",
	},
	Swimming = {
		SoundId = "rbxasset://sounds/action_swim.mp3",
		Looped = true,
		Pitch = 1.6,
	},
}

 -- wait for the first of the passed signals to fire
local function waitForFirst(...)
	local shunt = Instance.new("BindableEvent")
	local slots = {...}

	local function fire(...)
		for i = 1, #slots do
			slots[i]:Disconnect()
		end

		return shunt:Fire(...)
	end

	for i = 1, #slots do
		slots[i] = slots[i]:Connect(fire)
	end

	return shunt.Event:Wait()
end


Prompt: -- Get references to the DockShelf and its children

Response:
local dockShelf = script.Parent.Parent.Parent.Parent.Parent.DockShelf
local aFinderButton = dockShelf.BMessages
local opened = aFinderButton.Opened
local Minimalise = script.Parent
local window = script.Parent.Parent.Parent
local msgbar = window.MesgBar


Prompt: --Made by Luckymaxer

Response:
Tool = script.Parent
Handle = Tool:WaitForChild("Handle")

Players = game:GetService("Players")
RunService = game:GetService("RunService")
UserInputService = game:GetService("UserInputService")

Animations = {}
LocalObjects = {}

Remotes = Tool:WaitForChild("Remotes")
ServerControl = Remotes:WaitForChild("ServerControl")
ClientControl = Remotes:WaitForChild("ClientControl")

ToolEquipped = false

function SetAnimation(mode, value)
	if not ToolEquipped or not CheckIfAlive() then
		return
	end
	if mode == "PlayAnimation" and value and ToolEquipped and Humanoid then
		for i, v in pairs(Animations) do
			if v.Animation == value.Animation then
				v.AnimationTrack:Stop()
				table.remove(Animations, i)
			end
		end
		local AnimationTrack = Humanoid:LoadAnimation(value.Animation)
		table.insert(Animations, {Animation = value.Animation, AnimationTrack = AnimationTrack})
		AnimationTrack:Play(value.FadeTime, value.Weight, value.Speed)
	elseif mode == "StopAnimation" and value then
		for i, v in pairs(Animations) do
			if v.Animation == value.Animation then
				v.AnimationTrack:Stop(value.FadeTime)
				table.remove(Animations, i)
			end
		end
	end
end

function DisableJump(Boolean)
	if PreventJump then
		PreventJump:disconnect()
	end
	if Boolean then
		PreventJump = Humanoid.Changed:connect(function(Property)
			if Property ==  "Jump" then
				Humanoid.Jump = false
			end
		end)
	end
end

function CheckIfAlive()
	return (((Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and Head and Head.Parent and Player and Player.Parent) and true) or false)
end

function Equipped(Mouse)
	Character = Tool.Parent
	Player = Players:GetPlayerFromCharacter(Character)
	Humanoid = Character:FindFirstChild("Humanoid")
	Head = Character:FindFirstChild("Head")
	ToolEquipped = true
	if not CheckIfAlive() then
		return
	end
	PlayerMouse = Player:GetMouse()
	Mouse.KeyDown:connect(function(Key)
		InvokeServer("KeyPress", {Key = Key, Down = true})
	end)
	Mouse.KeyUp:connect(function(Key)
		InvokeServer("KeyPress", {Key = Key, Down = false})
	end)
end

function Unequipped()
	ToolEquipped = false
	for i, v in pairs(Animations) do
		if v and v.AnimationTrack then
			v.AnimationTrack:Stop()
		end
	end
	for i, v in pairs(LocalObjects) do
		if v.Object then
			v.Object.LocalTransparencyModifier = 0
		end
	end
	for i, v in pairs({PreventJump, ObjectLocalTransparencyModifier}) do
		if v then
			v:disconnect()
		end
	end
	Animations = {}
	LocalObjects = {}
end

function InvokeServer(mode, value)
	local ServerReturn
	pcall(function()
		ServerReturn = ServerControl:InvokeServer(mode, value)
	end)
	return ServerReturn
end

function OnClientInvoke(mode, value)
	if not ToolEquipped or not CheckIfAlive() or not mode then
		return
	end
	if mode == "PlayAnimation" and value then
		SetAnimation("PlayAnimation", value)
	elseif mode == "StopAnimation" and value then
		SetAnimation("StopAnimation", value)
	elseif mode == "PlaySound" and value then
		value:Play()
	elseif mode == "StopSound" and value then
		value:Stop()
	elseif mode == "MouseData" then
		return {Position = PlayerMouse.Hit.p, Target = PlayerMouse.Target}
	elseif mode == "DisableJump" then
		DisableJump(value)
	elseif mode == "SetLocalTransparencyModifier" and value then
		pcall(function()
			local ObjectFound = false
			for i, v in pairs(LocalObjects) do
				if v == value then
					ObjectFound = true
				end
			end
			if not ObjectFound then
				table.insert(LocalObjects, value)
				if ObjectLocalTransparencyModifier then
					ObjectLocalTransparencyModifier:disconnect()
				end
				ObjectLocalTransparencyModifier = RunService.RenderStepped:connect(function()
					local Camera = game:GetService("Workspace").CurrentCamera
					for i, v in pairs(LocalObjects) do
						if v.Object and v.Object.Parent then
							local CurrentTransparency = v.Object.LocalTransparencyModifier
							local ViewDistance = (Camera.CoordinateFrame.p - Head.Position).Magnitude
							if ((not v.AutoUpdate and (CurrentTransparency == 1 or CurrentTransparency == 0)) or v.AutoUpdate) then
								if ((v.Distance and ViewDistance <= v.Distance) or not v.Distance) then
									v.Object.LocalTransparencyModifier = v.Transparency
								else
									v.Object.LocalTransparencyModifier = 0
								end
							end
						else
							table.remove(LocalObjects, i)
						end
					end
				end)
			end
		end)
	end
end

ClientControl.OnClientInvoke = OnClientInvoke
Tool.Equipped:connect(Equipped)
Tool.Unequipped:connect(Unequipped)


Prompt: --{{ Reapeats to make the script look better }}--

Response: local button = script.Parent


Prompt: ----  \/Traffic\/

Response:
model = script.Parent
wait(0.5)
currentP = "Off"
script.Parent.Events.Traffic.OnServerEvent:Connect( function(player, pattern)
	if script.Parent.Values.Traffic.Value == 0 then
		script.Parent.Values.Traffic.Value = 1
	elseif script.Parent.Values.Traffic.Value == 1 then
		script.Parent.Values.Traffic.Value = 2
	elseif script.Parent.Values.Traffic.Value == 2 then
		script.Parent.Values.Traffic.Value = 3
	elseif script.Parent.Values.Traffic.Value == 3 then
		script.Parent.Values.Traffic.Value = 4
	elseif script.Parent.Values.Traffic.Value == 4 then
		script.Parent.Values.Traffic.Value = 0
	end
end)


Prompt: --{ id = "slash.xml", weight = 10 }

Response:
},
toollunge = {
{ id = "http://www.roblox.com/asset/?id=129967478", weight = 10 }
},
wave = {
{ id = "http://www.roblox.com/asset/?id=128777973", weight = 10 }
},
point = {
{ id = "http://www.roblox.com/asset/?id=128853357", weight = 10 }
},
dance1 = {
{ id = "http://www.roblox.com/asset/?id=182435998", weight = 10 },
{ id = "http://www.roblox.com/asset/?id=182491037", weight = 10 },
{ id = "http://www.roblox.com/asset/?id=182491065", weight = 10 }
},
dance2 = {
{ id = "http://www.roblox.com/asset/?id=182436842", weight = 10 },
{ id = "http://www.roblox.com/asset/?id=182491248", weight = 10 },
{ id = "http://www.roblox.com/asset/?id=182491277", weight = 10 }
},
dance3 = {
{ id = "http://www.roblox.com/asset/?id=182436935", weight = 10 },
{ id = "http://www.roblox.com/asset/?id=182491368", weight = 10 },
{ id = "http://www.roblox.com/asset/?id=182491423", weight = 10 }
},
laugh = {
{ id = "http://www.roblox.com/asset/?id=129423131", weight = 10 }
},
cheer = {
{ id = "http://www.roblox.com/asset/?id=129423030", weight = 10 }
},
}
local dances = {"dance1", "dance2", "dance3"}


Prompt: --- Used to mute a speaker so that this speaker does not see their messages.

Response:
function methods:AddMutedSpeaker(speakerName)
	self.MutedSpeakers[speakerName:lower()] = true
end

function methods:RemoveMutedSpeaker(speakerName)
	self.MutedSpeakers[speakerName:lower()] = false
end

function methods:IsSpeakerMuted(speakerName)
	return self.MutedSpeakers[speakerName:lower()]
end


Prompt: -- services

Response:
local UserInputService	= game:GetService("UserInputService")
local ReplicatedStorage	= game:GetService("ReplicatedStorage")
local RunService		= game:GetService("RunService")
local Players			= game:GetService("Players")


Prompt: --- Sets the handler for a certain event type

Response:
function Cmdr:HandleEvent(name, callback)
	self.Events[name] = callback
end


Prompt: ---Semi Settings---

Response:
			if Settings.Mode == "Semi" and Settings.FireModes.Burst == true then
				Gui.FText.Text = "Burst"
				Settings.Mode = "Burst"
			elseif Settings.Mode == "Semi" and Settings.FireModes.Burst == false and Settings.FireModes.Auto == true then
				Gui.FText.Text = "Auto"
				Settings.Mode = "Auto"
			elseif Settings.Mode == "Semi" and Settings.FireModes.Burst == false and Settings.FireModes.Auto == false and Settings.FireModes.Explosive == true then
				Gui.FText.Text = "Explosive"
				Settings.Mode = "Explosive"


Prompt: --- Calls self:FlushAutoExecBuffer at the end of the frame

Response:
function Registry:FlushAutoExecBufferDeferred()
	if self.AutoExecFlushConnection then
		return
	end

	self.AutoExecFlushConnection = RunService.Heartbeat:Connect(function()
		self.AutoExecFlushConnection:Disconnect()
		self.AutoExecFlushConnection = nil
		self:FlushAutoExecBuffer()
	end)
end


Prompt:
-- you don't have to change these if you chose auto setup
-- put these to true if you have these plugins in your car, otherwise leave them as false

Response:
smoke = false
backfire = false
horn = false
brakewhistle = false
ignition = false
audioname = "Start" -- the name of your startup audio (defaults as "Start") (only works with ignition on)


Prompt: -- Don't edit below unless you know what you're doing.

Response:
local O = true
function onClicked()
if O == true then
	O = false
	One()

elseif O == false then
	O = true
    Two()
end
end

script.Parent.MouseButton1Down:connect(onClicked)


Response:
local WaitTime = 1	-- Change this to the amount of time it takes for the button to re-enable.
local modelname = "Air Raid Extreme"	-- If your model is not named this, then make the purple words the same name as the model!


Prompt: -- anon Image ID http://www.roblox.com/Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=420&ht=420&aid=4823036

Response:
local GameData = {}

for _, Script in next, script:GetDescendants() do
	if Script:IsA("ModuleScript") then
		for Key, Data in next, require(Script) do
			GameData[Key] = Data
		end
	end
end

return GameData


Prompt: --this is a function to get player character rig

Response:
local function DetectRigAsync(Char)
	local Hum = Char:FindFirstChildOfClass("Humanoid")

	if Hum then
		if Hum.RigType == Enum.HumanoidRigType.R15 then
			return "R15"
		elseif Hum.RigType == Enum.HumanoidRigType.R6 then
			return "R6"
		end
	end
end

function RayCast(startPos, vec, rayLength)
	local Origin = startPos

	local Direction = vec * rayLength

	local Params = RaycastParams.new()
	Params.FilterType = Enum.RaycastFilterType.Blacklist
	Params.IgnoreWater = true
	Params.FilterDescendantsInstances = {Tool.Parent, workspace.BulletsFolder, Tool}

	local raycastResult = workspace:Raycast(Origin, Direction, Params)

	if raycastResult then
		return raycastResult.Instance, raycastResult.Position
	end
end

local function Reload()
	if not Reloading then
		Reloading = true

		if AmmoInClip ~= ClipSize and SpareAmmo > 0 then
			if RecoilTrack then
				RecoilTrack:Stop()
			end
			if WeaponGui and WeaponGui:FindFirstChild('Crosshair') then
				if WeaponGui.Crosshair:FindFirstChild('ReloadingLabel') then
					WeaponGui.Crosshair.ReloadingLabel.Visible = true
				end
			end
			if ReloadTrack then
				ReloadTrack:Play()
			end
			script.Parent.Handle.Reload:Play()
			task.wait(ReloadTime)
			-- Only use as much ammo as you have
			local ammoToUse = math.min(ClipSize - AmmoInClip, SpareAmmo)
			AmmoInClip = AmmoInClip + ammoToUse
			SpareAmmo = SpareAmmo - ammoToUse
			UpdateAmmo(AmmoInClip)
			--WeaponGui.Reload.Visible = false
			if ReloadTrack then
				ReloadTrack:Stop()
			end
		end
		Reloading = false
	end
end

function OnFire()
	if IsShooting then return end
	if MyHumanoid and MyHumanoid.Health > 0 then
		if RecoilTrack and AmmoInClip > 0 then
			RecoilTrack:Play()
		end
		IsShooting = true
		while LeftButtonDown and AmmoInClip > 0 and not Reloading do
			if Spread and not DecreasedAimLastShot then
				Spread = math.min(MaxSpread, Spread + AimInaccuracyStepAmount)
				UpdateCrosshair(Spread)
			end
			DecreasedAimLastShot = not DecreasedAimLastShot
			if Handle:FindFirstChild('FireSound') then
				Pitch.Pitch = .8 + (math.random() * .5)
				Handle.FireSound:Play()
				Handle.Flash.Enabled = true
				flare.MuzzleFlash.Enabled = true
				--Handle.Smoke.Enabled=true --This is optional
			end
			if MyMouse then
				local targetPoint = MyMouse.Hit.Position
				local shootDirection = (targetPoint - Handle.Position).unit

				shootDirection = CFrame.Angles((0.5 - math.random()) * 2 * Spread,
					(0.5 - math.random()) * 2 * Spread,
					(0.5 - math.random()) * 2 * Spread) * shootDirection
				local hitObject, bulletPos = RayCast(Handle.Position, shootDirection, Range)
				local bullet

				if hitObject then
					bulletRE:FireServer(bulletPos)
					WeaponGui.Crosshair.Hit:Play()
				end
				if hitObject and hitObject.Parent then
					local hitHumanoid = hitObject.Parent:FindFirstChild("Humanoid")
					if hitHumanoid then
						local hitPlayer = game.Players:GetPlayerFromCharacter(hitHumanoid.Parent)
						if MyPlayer.Neutral or (hitPlayer and hitPlayer.TeamColor ~= MyPlayer.TeamColor) then
							ShootRE:FireServer(hitHumanoid, Damage)
							if bullet then
								bullet:Destroy()
								bullet = nil
								--bullet.Transparency = 1
							end
							task.spawn(UpdateTargetHit)
						end
					end
				end
				AmmoInClip = AmmoInClip - 1
				UpdateAmmo(AmmoInClip)
			end
			task.wait(FireRate)
		end
		Handle.Flash.Enabled = false
		IsShooting = false
		flare.MuzzleFlash.Enabled = false
		--Handle.Smoke.Enabled=false --This is optional
		if AmmoInClip == 0 then
			Handle.Tick:Play()
			--WeaponGui.Reload.Visible = true
			Reload()
		end
		if RecoilTrack then
			RecoilTrack:Stop()
		end
	end
end

local TargetHits = 0
function UpdateTargetHit()
	TargetHits = TargetHits + 1
	if WeaponGui and WeaponGui:FindFirstChild('Crosshair') and WeaponGui.Crosshair:FindFirstChild('TargetHitImage') then
		WeaponGui.Crosshair.TargetHitImage.Visible = true
	end
	task.wait(0.5)
	TargetHits = TargetHits - 1
	if TargetHits == 0 and WeaponGui and WeaponGui:FindFirstChild('Crosshair') and WeaponGui.Crosshair:FindFirstChild('TargetHitImage') then
		WeaponGui.Crosshair.TargetHitImage.Visible = false
	end
end

function UpdateCrosshair(value, mouse)
	if WeaponGui then
		local absoluteY = 650
		WeaponGui.Crosshair:TweenSize(
			UDim2.new(0, value * absoluteY * 2 + 23, 0, value * absoluteY * 2 + 23),
			Enum.EasingDirection.Out,
			Enum.EasingStyle.Linear,
			0.33)
	end
end

function UpdateAmmo(value)
	if WeaponGui and WeaponGui:FindFirstChild('AmmoHud') and WeaponGui.AmmoHud:FindFirstChild('ClipAmmo') then
		WeaponGui.AmmoHud.ClipAmmo.Text = AmmoInClip
		if value > 0 and WeaponGui:FindFirstChild('Crosshair') and WeaponGui.Crosshair:FindFirstChild('ReloadingLabel') then
			WeaponGui.Crosshair.ReloadingLabel.Visible = false
		end
	end
	if WeaponGui and WeaponGui:FindFirstChild('AmmoHud') and WeaponGui.AmmoHud:FindFirstChild('TotalAmmo') then
		WeaponGui.AmmoHud.TotalAmmo.Text = SpareAmmo
	end
end

function OnMouseDown()
	LeftButtonDown = true
	OnFire()
end

function OnMouseUp()
	LeftButtonDown = false
end

function OnKeyDown(key)
	if string.lower(key) == 'r' then
		Reload()
		if RecoilTrack then
			RecoilTrack:Stop()
		end
	end
end

local TransparencyConnections = {}

function OnEquipped(mouse)

	Handle.EquipSound:Play()
	Handle.EquipSound2:Play()
	Handle.UnequipSound:Stop()
	RecoilAnim = WaitForChild(Tool, 'Recoil')
	ReloadAnim = WaitForChild(Tool, 'Reload')
	FireSound  = WaitForChild(Handle, 'FireSound')

	MyCharacter = Tool.Parent

	MyPlayer = game:GetService('Players'):GetPlayerFromCharacter(MyCharacter)
	MyHumanoid = MyCharacter:FindFirstChild('Humanoid')
	MyTorso = MyCharacter:FindFirstChild('Torso')
	MyMouse = mouse
	WeaponGui = WaitForChild(Tool, 'WeaponHud'):Clone()

	if FPSHandsEnbled then
		if AutoFirstPerson then
			MyPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
		end

		local Rig = DetectRigAsync(MyCharacter)

		if Rig == "R15" then
			local WhitelistedBodyParts = {"LeftHand", "LeftLowerArm", "LeftUpperArm", "RightHand", "RightLowerArm", "RightUpperArm"}

			for i, bodypart in pairs(MyCharacter:GetDescendants()) do
				if table.find(WhitelistedBodyParts, bodypart.Name) and bodypart:IsA("BasePart") then
					bodypart.LocalTransparencyModifier = bodypart.Transparency

					TransparencyConnections[bodypart.Name] = bodypart:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
						bodypart.LocalTransparencyModifier = bodypart.Transparency
					end)
				end
			end
		elseif Rig == "R6" then
			local WhitelistedBodyParts = {"Right Arm", "Left Arm"}

			for i, bodypart in pairs(MyCharacter:GetDescendants()) do
				if table.find(WhitelistedBodyParts, bodypart.Name) and bodypart:IsA("BasePart") then
					bodypart.LocalTransparencyModifier = bodypart.Transparency

					TransparencyConnections[bodypart.Name] = bodypart:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
						bodypart.LocalTransparencyModifier = bodypart.Transparency
					end)
				end
			end

		end
	end

	if WeaponGui and MyPlayer then
		WeaponGui.Parent = MyPlayer.PlayerGui
		UpdateAmmo(AmmoInClip)
	end
	if RecoilAnim then
		RecoilTrack = MyHumanoid:LoadAnimation(RecoilAnim)
	end

	if ReloadAnim then
		ReloadTrack = MyHumanoid:LoadAnimation(ReloadAnim)
	end

	if MyMouse then
		-- Disable mouse icon
		MyMouse.Icon = "http://www.roblox.com/asset/?id=18662154"
		MyMouse.Button1Down:connect(OnMouseDown)
		MyMouse.Button1Up:connect(OnMouseUp)
		MyMouse.KeyDown:connect(OnKeyDown)
	end
end


Prompt:
--[[**
	<description>
	Takes a function to be called when :Get() is first called and there is a value in the data store. This function must return a value to set to. Used for deserializing.
	</description>

	<parameter name = "modifier">
	The modifier function.
	</parameter>
**--]]

Response:
function DataStore:BeforeInitialGet(modifier)
	table.insert(self.beforeInitialGet, modifier)
end


Prompt: --<Local Functions>--

Response:
local function CreateSound(soundID, volume, parent)
	local sound = Instance.new("Sound", parent);
	sound.Volume = 0;
	sound.Name = "_PlayOnTouchedSound";
	sound.SoundId = "rbxassetid://".. soundID;
	sound.Looped = true;

	sound:Play()

	repeat
		sound.Volume = sound.Volume + .1;
		wait(.1);
	until
		sound.Volume >= volume;
end;


Prompt: -- @outline // RUNNERS

Response:
function Ping.Update()
	if tick() - LastUpdate < REQUEST_INTERVAL then return end

	LastUpdate = tick()
	for _,v in pairs(game.Players:GetChildren()) do
		Ping.UpdatePlayer(v)
	end
end

function Ping.Init()
	System.Remotes.ConnectEvent("Ping", function(plr, Code)
		if type(Code) ~= "number" or not Pool[plr] or Pool[plr].Code == -1 or Pool[plr].Code ~= Code then return end

		Pool[plr].Value = tick() - Pool[plr].Time
		Pool[plr].Code = -1
	end)

	game.Players.PlayerAdded:Connect(function(plr)
		Pool[plr] = {
			Code = -1,
			Value = 0,
			Time = tick()
		}
	end)

	game.Players.PlayerRemoving:Connect(function(plr)
		Pool[plr] = nil
	end)
end

function Ping.ClientInit()
	Pool[game.Players.LocalPlayer] = {Value = 0}
	System.Remotes.ConnectEvent("Ping", function(tbl)
		Pool[game.Players.LocalPlayer] = {Value = tbl.Value}

		System.Remotes.FireServer("Ping", tbl.Code)
	end)
end

return Ping


Prompt: --If necessary change the last word to:

Response:
	--Signal1
	--Signal1a
	--Signal2
	--Signal2a


Prompt: -- Left Legs

Response:
character.Constraint.ConstraintLeftUpperLeg.Attachment0 = LUL
character.Constraint.ConstraintLeftUpperLeg.Attachment1 = LULRig
character.Constraint.ConstraintLeftLowerLeg.Attachment0 = LLL
character.Constraint.ConstraintLeftLowerLeg.Attachment1 = LLLRig
character.Constraint.ConstraintLeftFoot.Attachment0 = LF
character.Constraint.ConstraintLeftFoot.Attachment1 = LFRig


Prompt: --[[Engine]]

Response:
	--Torque Curve
	Tune.Horsepower		= 415	--	[TORQUE CURVE VISUAL]
	Tune.IdleRPM		= 900		--		https://www.desmos.com/calculator/2uo3hqwdhf
	Tune.PeakRPM		= 9200		--		Use sliders to manipulate values
	Tune.Redline		= 9700
	Tune.EqPoint		= 7250
	Tune.PeakSharpness	= 9.5
	Tune.CurveMult		= 0.15

	--Incline Compensation
	Tune.InclineComp	= 1.7			-- Torque compensation multiplier for inclines (applies gradient from 0-90 degrees)

	--Misc
	Tune.RevAccel		= 150		-- RPM acceleration when clutch is off
	Tune.RevDecay		= 75		-- RPM decay when clutch is off
	Tune.RevBounce		= 500		-- RPM kickback from redline
	Tune.IdleThrottle	= 3			-- Percent throttle at idle
	Tune.ClutchTol		= 500		-- Clutch engagement threshold (higher = faster response)


Prompt:
--[[
	Start
]]

Response:
if PATROL_ENABLED then
	coroutine.wrap(function()
		patrol()
	end)()
end

coroutine.wrap(function()
	while isAlive() do
		if target and not attacking and isInstaceAttackable(target) then
			attack()
		end

		wait(1)
	end
end)()


Prompt:
--////////////////////////////// Include
--//////////////////////////////////////

Response:
local Chat = game:GetService("Chat")
local clientChatModules = Chat:WaitForChild("ClientChatModules")
local modulesFolder = script.Parent
local moduleChatChannel = require(modulesFolder:WaitForChild("ChatChannel"))
local ChatSettings = require(clientChatModules:WaitForChild("ChatSettings"))
local CurveUtil = require(modulesFolder:WaitForChild("CurveUtil"))


Prompt: --------LEFT DOOR --------

Response:
game.Workspace.doorleft.l11.BrickColor = BrickColor.new(106)
game.Workspace.doorleft.l12.BrickColor = BrickColor.new(106)
game.Workspace.doorleft.l13.BrickColor = BrickColor.new(106)
game.Workspace.doorleft.l41.BrickColor = BrickColor.new(106)
game.Workspace.doorleft.l42.BrickColor = BrickColor.new(106)
game.Workspace.doorleft.l43.BrickColor = BrickColor.new(106)
game.Workspace.doorleft.l71.BrickColor = BrickColor.new(106)
game.Workspace.doorleft.l72.BrickColor = BrickColor.new(106)
game.Workspace.doorleft.l73.BrickColor = BrickColor.new(106)

game.Workspace.doorleft.l21.BrickColor = BrickColor.new(21)
game.Workspace.doorleft.l22.BrickColor = BrickColor.new(21)
game.Workspace.doorleft.l23.BrickColor = BrickColor.new(21)
game.Workspace.doorleft.l51.BrickColor = BrickColor.new(21)
game.Workspace.doorleft.l52.BrickColor = BrickColor.new(21)
game.Workspace.doorleft.l53.BrickColor = BrickColor.new(21)

game.Workspace.doorleft.l31.BrickColor = BrickColor.new(133)
game.Workspace.doorleft.l32.BrickColor = BrickColor.new(133)
game.Workspace.doorleft.l33.BrickColor = BrickColor.new(133)
game.Workspace.doorleft.l61.BrickColor = BrickColor.new(133)
game.Workspace.doorleft.l62.BrickColor = BrickColor.new(133)
game.Workspace.doorleft.l63.BrickColor = BrickColor.new(133)

game.Workspace.doorleft.pillar.BrickColor = BrickColor.new(106)


Response:
	 TeamKill = true					--- Enable TeamKill?
	,TeamDmgMult = 1					--- Between 0-1 | This will make you cause less damage if you hit your teammate

	,ReplicatedBullets = true			--- Keep in mind that some bullets will pass through surfaces...

	,AntiBunnyHop = true				--- Enable anti bunny hop system?
	,JumpCoolDown = 1.5					--- Seconds before you can jump again
	,JumpPower = 0						--- Jump power, default is 50

	,RealisticLaser = true				--- True = Laser line is invisible
	,ReplicatedLaser = true
	,ReplicatedFlashlight = true

	,EnableRagdoll = true				--- Enable ragdoll death?
	,TeamTags = true					--- Aaaaaaa
	,HitmarkerSound = false				--- GGWP MLG 360 NO SCOPE xD
	,Crosshair = true					--- Crosshair for Hipfire shooters and arcade modes
	,CrosshairOffset = 5				--- Crosshair size offset


Prompt: -- Tips

Response:
DEFAULT_FORCED_GROUP_VALUES["tip"] = 1

function Icon:setTip(text)
	assert(typeof(text) == "string" or text == nil, "Expected string, got "..typeof(text))
	local textSize = textService:GetTextSize(text, 12, Enum.Font.GothamSemibold, Vector2.new(1000, 20-6))
	self.instances.tipLabel.Text = text
	self.instances.tipFrame.Size = UDim2.new(0, textSize.X+6, 0, 20)
	self.instances.tipFrame.Parent = (text and activeItems) or self.instances.iconContainer
	self.tipText = text

	local tipMaid = Maid.new()
	self._maid.tipMaid = tipMaid
	tipMaid:give(self.hoverStarted:Connect(function()
		if not self.isSelected then
			self:displayTip(true)
		end
	end))
	tipMaid:give(self.hoverEnded:Connect(function()
		self:displayTip(false)
	end))
	tipMaid:give(self.selected:Connect(function()
		if self.hovering then
			self:displayTip(false)
		end
	end))
	self:displayTip(self.hovering)
	return self
end

function Icon:displayTip(bool)
	if userInputService.TouchEnabled and not self._draggingFinger then return end

	-- Determine caption visibility
	local isVisible = self.tipVisible or false
	if typeof(bool) == "boolean" then
		isVisible = bool
	end
	self.tipVisible = isVisible

	-- Have tip position track mouse or finger
	local tipFrame = self.instances.tipFrame
	if isVisible then
		-- When the user moves their cursor/finger, update tip to match the position
		local function updateTipPositon(x, y)
			local newX = x
			local newY = y
			local camera = workspace.CurrentCamera
			local viewportSize = camera and camera.ViewportSize
			if userInputService.TouchEnabled then
				--tipFrame.AnchorPoint = Vector2.new(0.5, 0.5)
				local desiredX = newX - tipFrame.Size.X.Offset/2
				local minX = 0
				local maxX = viewportSize.X - tipFrame.Size.X.Offset
				local desiredY = newY + THUMB_OFFSET + 60
				local minY = tipFrame.AbsoluteSize.Y + THUMB_OFFSET + 64 + 3
				local maxY = viewportSize.Y - tipFrame.Size.Y.Offset
				newX = math.clamp(desiredX, minX, maxX)
				newY = math.clamp(desiredY, minY, maxY)
			elseif IconController.controllerModeEnabled then
				local indicator = TopbarPlusGui.Indicator
				local newPos = indicator.AbsolutePosition
				newX = newPos.X - tipFrame.Size.X.Offset/2 + indicator.AbsoluteSize.X/2
				newY = newPos.Y + 90
			else
				local desiredX = newX
				local minX = 0
				local maxX = viewportSize.X - tipFrame.Size.X.Offset - 48
				local desiredY = newY
				local minY = tipFrame.Size.Y.Offset+3
				local maxY = viewportSize.Y
				newX = math.clamp(desiredX, minX, maxX)
				newY = math.clamp(desiredY, minY, maxY)
			end
			--local difX = tipFrame.AbsolutePosition.X - tipFrame.Position.X.Offset
			--local difY = tipFrame.AbsolutePosition.Y - tipFrame.Position.Y.Offset
			--local globalX = newX - difX
			--local globalY = newY - difY
			--tipFrame.Position = UDim2.new(0, globalX, 0, globalY-55)
			tipFrame.Position = UDim2.new(0, newX, 0, newY-20)
		end
		local cursorLocation = userInputService:GetMouseLocation()
		if cursorLocation then
			updateTipPositon(cursorLocation.X, cursorLocation.Y)
		end
		self._hoveringMaid:give(self.instances.iconButton.MouseMoved:Connect(updateTipPositon))
	end

	-- Change transparency of relavent tip instances
	for _, settingName in pairs(self._groupSettings.tip) do
		local settingDetail = self._settingsDictionary[settingName]
		settingDetail.useForcedGroupValue = not isVisible
		self:_update(settingName)
	end
end


Prompt: --[[Steering]]

Response:
	Tune.SteerInner		= 45		-- Inner wheel steering angle (in degrees)
	Tune.SteerOuter		= 38		-- Outer wheel steering angle (in degrees)
	Tune.SteerSpeed		= .18		-- Steering increment per tick (in degrees)
	Tune.ReturnSpeed	= .2		-- Steering increment per tick (in degrees)
	Tune.SteerDecay		= 330		-- Speed of gradient cutoff (in SPS)
	Tune.MinSteer		= 10		-- Minimum steering at max steer decay (in percent)
	Tune.MSteerExp		= 1			-- Mouse steering exponential degree

	--Steer Gyro Tuning
	Tune.SteerD			= 1000		-- Steering Dampening
	Tune.SteerMaxTorque	= 50000		-- Steering Force
	Tune.SteerP			= 100000	-- Steering Aggressiveness


Prompt:
--[[**
	ensures Lua primitive boolean type

	@param value The value to check against

	@returns True iff the condition is satisfied, false otherwise
**--]]

Response: t.boolean = primitive("boolean")


Prompt: -- initialize to idle

Response:
playAnimation("idle", 0.1, Humanoid)
pose = "Standing"


Prompt:
--[[
	Internal method used by the reconciler to clean up any resources held by
	this component instance.
]]

Response:
function Component:__unmount()
	if config.internalTypeChecks then
		internalAssert(Type.of(self) == Type.StatefulComponentInstance, "Invalid use of `__unmount`")
	end

	local internalData = self[InternalData]
	local virtualNode = internalData.virtualNode
	local reconciler = internalData.reconciler

	if self.willUnmount ~= nil then
		internalData.lifecyclePhase = ComponentLifecyclePhase.WillUnmount
		self:willUnmount()
	end

	for _, childNode in pairs(virtualNode.children) do
		reconciler.unmountVirtualNode(childNode)
	end
end


Prompt:
--[=[
	@param promise Promise
	@return Promise
	Gives the promise to the trove, which will cancel the promise if the trove is cleaned up or if the promise
	is removed. The exact promise is returned, thus allowing chaining.

	```lua
	trove:AddPromise(doSomethingThatReturnsAPromise())
		:andThen(function()
			print("Done")
		end)
	-- Will cancel the above promise (assuming it didn't resolve immediately)
	trove:Clean()

	local p = trove:AddPromise(doSomethingThatReturnsAPromise())
	-- Will also cancel the promise
	trove:Remove(p)
	```

	:::caution Promise v4 Only
	This is only compatible with the [roblox-lua-promise](https://eryn.io/roblox-lua-promise/) library, version 4.
	:::
]=]

Response:
function Trove:AddPromise(promise)
	AssertPromiseLike(promise)
	if promise:getStatus() == "Started" then
		promise:finally(function()
			return self:_findAndRemoveFromObjects(promise, false)
		end)
		self:Add(promise, "cancel")
	end
	return promise
end


Prompt: -- Decompiled with the Synapse X Luau decompiler.

Response:
local v1 = {
	i = {
		Hand = "rbxassetid://9873368030",
		Eye = "rbxassetid://9873864431",
		Bulb = "rbxassetid://9874204694"
	}
};
v1.icons = {
	Default = v1.i.Hand,
	Interact = v1.i.Hand,
	Inspect = v1.i.Eye,
	Hint = v1.i.Bulb
};
function v1.getIcon(p1)
	local v2 = v1.icons[p1];
	if v2 then
		return v2;
	end;
	return v1.icons.Default;
end;
return v1;


Response:
	,Distance = 0
	,BDrop = 0
	,BSpeed = 0

	,SuppressMaxDistance = 0	--- Studs
	,SuppressTime = 0			--- Seconds

	,BulletWhiz = false
	,BWEmitter = 0
	,BWMaxDistance = 0

	,BulletFlare = false
	,BulletFlareColor = Color3.fromRGB(0,0,0)

	,Tracer = false
	,TracerColor = Color3.fromRGB(0,0,0)
	,TracerLightEmission = 0
	,TracerLightInfluence = 0
	,TracerLifeTime = 0
	,TracerWidth = 0
	,RandomTracer = false
	,TracerEveryXShots = 0
	,TracerChance = 0

	,BulletLight = false
	,BulletLightBrightness = 0
	,BulletLightColor = Color3.fromRGB(0,0,0)
	,BulletLightRange = 0

	,ExplosiveHit = false
	,ExPressure = 0
	,ExpRadius = 0
	,DestroyJointRadiusPercent = 0	--- Between 0 & 1
	,ExplosionDamage = 0

	,LauncherDamage = 0
	,LauncherRadius = 0
	,LauncherPressure = 0
	,LauncherDestroyJointRadiusPercent = 0