Response:
function FixVars() --This function fixes any errors in the Customize folder
	Acceleration2 = (Acceleration.Value < 0 and 0 or Acceleration.Value > 1000 and 1000 or Acceleration.Value)
	MaxBank2 = (MaxBank.Value < -90 and -90 or MaxBank.Value > 90 and 90 or MaxBank.Value)
	MaxSpeed2 = (MaxSpeed.Value < 0 and 0 or MaxSpeed.Value < StallSpeed.Value and StallSpeed.Value or MaxSpeed.Value)
	StallSpeed2 = (StallSpeed.Value < 0 and 0 or StallSpeed.Value > MaxSpeed.Value and MaxSpeed.Value or StallSpeed.Value)
	TurnSpeed2 = (TurnSpeed.Value < 0 and 0 or TurnSpeed.Value)
	ThrottleInc2 = (ThrottleInc.Value < 0 and 0 or ThrottleInc.Value)
	MaxAltitude2 = (MaxAltitude.Value < MinAltitude.Value and MinAltitude.Value or MaxAltitude.Value)
	MinAltitude2 = (MinAltitude.Value > MaxAltitude.Value and MaxAltitude.Value or MinAltitude.Value)
	MissileTime2 = (ReloadTimes.Missiles.Value < 0 and 0 or ReloadTimes.Missiles.Value)
	RocketTime2 = (ReloadTimes.Rockets.Value < 0 and 0 or ReloadTimes.Rockets.Value)
	GunTime2 = (ReloadTimes.Guns.Value < 0 and 0 or ReloadTimes.Guns.Value)
	FlareTime2 = (ReloadTimes.Flares.Value < 0 and 0 or ReloadTimes.Flares.Value)
	BombTime2 = (ReloadTimes.Bombs.Value < 0 and 0 or ReloadTimes.Bombs.Value)
	CameraType2 = (pcall(function() Camera.CameraType = CameraType.Value end) and CameraType.Value or "Custom")
	PlaneName2 = (PlaneName.Value == "" and "Plane" or PlaneName.Value)
	if WeaponsValue.Value then
		if WeaponsValue.Missiles.Value or WeaponsValue.Bombs.Value then
			Targetable2 = true
		elseif (not (WeaponsValue.Missiles.Value and WeaponsValue.Bombs.Value)) then
			Targetable2 = false
		end
	elseif (not WeaponsValue.Value) then
		Targetable2 = false
	end
	if FlightControls.SpeedUp.Value == "ArrowKeyUp" then
		SpeedUp2 = 17
		SUAK = true
	elseif FlightControls.SpeedUp.Value == "ArrowKeyDown" then
		SpeedUp2 = 18
		SUAK = true
	else
		SpeedUp2 = FlightControls.SpeedUp.Value
		SUAK = false
	end
	if FlightControls.SlowDown.Value == "ArrowKeyUp" then
		SlowDown2 = 17
		SDAK = true
	elseif FlightControls.SlowDown.Value == "ArrowKeyDown" then
		SlowDown2 = 18
		SDAK = true
	else
		SlowDown2 = FlightControls.SlowDown.Value
		SDAK = false
	end
	Engine.Direction.P = TurnSpeed2
end

function FireMachineGun(GunParent) --This function creates the bullets for the MachineGuns
	while FiringGun do
		for _,v in pairs(GunParent:GetChildren()) do --This is what allow you to put as many MachineGuns as you want in the Guns folder
			if v:IsA("BasePart") then
				if v.Name == "MachineGun" then
					local Part = Instance.new("Part")
					Part.BrickColor = BrickColor.new("Really red")
					Part.Name = "Bullet"
					Part.CanCollide = false
					Part.FormFactor = "Symmetric"
					Part.Size = Vector3.new(5,5,3)
					Part.BottomSurface = "Smooth"
					Part.TopSurface = "Smooth"
					local Mesh = Instance.new("BlockMesh")
					Mesh.Parent = Part
					Mesh.Scale = Vector3.new(1/25,1/25,1)
					local BV = Instance.new("BodyVelocity")
					BV.Parent = Part
					BV.maxForce = Vector3.new(math.huge,math.huge,math.huge)
					local PlaneTag = Instance.new("ObjectValue")
					PlaneTag.Parent = Part
					PlaneTag.Name = "PlaneTag"
					PlaneTag.Value = Plane
					Part.Touched:connect(function(Object) --This lets me call the "Touched" function, which means I don't need an external script
						if (not Object:IsDescendantOf(Character)) then
							local HitHumanoid = Object.Parent:findFirstChild("Humanoid")
							if HitHumanoid then
								HitHumanoid:TakeDamage(100) --This only damges the player if they don't have a forcefield
								local CreatorTag = Instance.new("ObjectValue")
								CreatorTag.Name = "creator"
								CreatorTag.Value = Player
								CreatorTag.Parent = HitHumanoid
							elseif (not HitHumanoid) then
								Object:BreakJoints()
							end
						end
					end)
					Part.Parent = game.Workspace
					Part.CFrame = v.CFrame + v.CFrame.lookVector * 10
					BV.velocity = (v.Velocity) + (Part.CFrame.lookVector * 2000) + (Vector3.new(0,0.15,0))
					delay(3,function() Part:Destroy() end)
				end
			end
		end
		wait(GunTime2)
	end
end

function FireRockets(GunParent) --This function creates the rockets for the rocket spawns
	for _,v in pairs(GunParent:GetChildren()) do --This allows you to put as many RocketSpawns as you want in the Rockets folder
		if v:IsA("BasePart") then
			if v.Name == "RocketSpawn" then
				local Exploded = false
				local Part1 = Instance.new("Part")
				Part1.BrickColor = BrickColor.new("White")
				Part1.Name = "Missile"
				Part1.CanCollide = false
				Part1.FormFactor = "Symmetric"
				Part1.Size = Vector3.new(1,1,5)
				Part1.BottomSurface = "Smooth"
				Part1.TopSurface = "Smooth"
				local Mesh = Instance.new("SpecialMesh")
				Mesh.Parent = Part1
				Mesh.MeshId = "http://www.roblox.com/asset/?id=2251534"
				Mesh.MeshType = "FileMesh"
				Mesh.Scale = Vector3.new(0.5,0.5,0.5)
				local Part2 = Instance.new("Part")
				Part2.Parent = Part1
				Part2.Transparency = 1
				Part2.Name = "Visual"
				Part2.CanCollide = false
				Part2.FormFactor = "Symmetric"
				Part2.Size = Vector3.new(1,1,1)
				Part2.BottomSurface = "Smooth"
				Part2.TopSurface = "Smooth"
				local Weld = Instance.new("Weld")
				Weld.Parent = Part1
				Weld.Part0 = Part1
				Weld.Part1 = Part2
				Weld.C0 = CFrame.new(0,0,4) * CFrame.Angles(math.rad(90),0,0)
				local BV = Instance.new("BodyVelocity")
				BV.Parent = Part1
				BV.maxForce = Vector3.new(math.huge,math.huge,math.huge)
				local BG = Instance.new("BodyGyro")
				BG.Parent = Part
				BG.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
				BG.cframe = v.CFrame
				local Fire = Instance.new("Fire")
				Fire.Parent = Part2
				Fire.Heat = 25
				Fire.Size = 10
				local Smoke = Instance.new("Smoke")
				Smoke.Parent = Part2
				Smoke.Color = Color3.new(200/255,200/255,200/255)
				Smoke.Opacity = 0.7
				Smoke.RiseVelocity = 25
				Smoke.Size = 10
				local PlaneTag = Instance.new("ObjectValue")
				PlaneTag.Parent = Part
				PlaneTag.Name = "PlaneTag"
				PlaneTag.Value = Plane
				Part1.Touched:connect(function(Object)
					if (not Exploded) then
						if (not Object:IsDescendantOf(Character)) then
							if Object.Name ~= "Missile" then
								Exploded = true
								local Explosion = Instance.new("Explosion",game.Workspace)
								Explosion.Position = Part1.Position
								Explosion.BlastPressure = 5000
								Explosion.BlastRadius = 10
								ScanPlayers(Part1.Position,10)
								Explosion.Parent = game.Workspace
								Part1:Destroy()
							end
						end
					end
				end)
				Part1.Parent = game.Workspace
				Part1.CFrame = v.CFrame + v.CFrame.lookVector * 10
				BV.velocity = Part1.CFrame.lookVector * 1250 + Vector3.new(0,0.15,0)
				delay(5,function() Part1:Destroy() end)
			end
		end
	end
end

function DeployFlares(GunParent) --This function creates the flares for the flare spawns
	for _,v in pairs(GunParent:GetChildren()) do
		if v:IsA("BasePart") then
			if v.Name == "FlareSpawn" then
				local RandomFactor = 40
				local RandomX = math.rad(math.random(-RandomFactor,RandomFactor))
				local RandomY = math.rad(math.random(-RandomFactor,RandomFactor))
				local Part = Instance.new("Part")
				Part.Transparency = 1
				Part.Name = "Flare"
				Part.CanCollide = false
				Part.FormFactor = "Symmetric"
				Part.Size = Vector3.new(1,1,1)
				Part.BottomSurface = "Smooth"
				Part.TopSurface = "Smooth"
				local BG = Instance.new("BillboardGui")
				BG.Parent = Part
				BG.Size = UDim2.new(10,0,10,0)
				local IL = Instance.new("ImageLabel")
				IL.Parent = BG
				IL.BackgroundTransparency = 1
				IL.Image = "http://www.roblox.com/asset/?id=43708803"
				IL.Size = UDim2.new(1,0,1,0)
				local Smoke = Instance.new("Smoke")
				Smoke.Parent = Part
				Smoke.Opacity = 0.5
				Smoke.RiseVelocity = 25
				Smoke.Size = 5
				local PL = Instance.new("PointLight")
				PL.Parent = Part
				PL.Brightness = 10
				PL.Color = Color3.new(1,1,0)
				PL.Range = 20
				Part.Parent = game.Workspace
				Part.CFrame = (v.CFrame + v.CFrame.lookVector * 5) * CFrame.Angles(RandomX,RandomY,0)
				Part.Velocity = Part.CFrame.lookVector * 150
				delay(5,function() Part:Destroy() end)
			end
		end
	end
end

function DropBomb(GunParent) --This function creates the non-guided bombs for the bomb spawns
	if (not Locked) then
		for _,v in pairs(GunParent:GetChildren()) do
			if v:IsA("BasePart") then
				if v.Name == "BombSpawn" then
					local Exploded = false
					local Part = Instance.new("Part")
					Part.Name = "Bomb"
					Part.CanCollide = false
					Part.FormFactor = "Symmetric"
					Part.Size = Vector3.new(2,2,9)
					Part.BottomSurface = "Smooth"
					Part.TopSurface = "Smooth"
					local Mesh = Instance.new("SpecialMesh")
					Mesh.Parent = Part
					Mesh.MeshId = "http://www.roblox.com/asset/?id=88782666"
					Mesh.MeshType = "FileMesh"
					Mesh.Scale = Vector3.new(4,4,4)
					Mesh.TextureId = "http://www.roblox.com/asset/?id=88782631"
					local BG = Instance.new("BodyGyro")
					BG.Parent = Part
					BG.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
					BG.cframe = v.CFrame * CFrame.Angles(math.rad(90),0,0)
					local PlaneTag = Instance.new("ObjectValue")
					PlaneTag.Parent = Part
					PlaneTag.Name = "PlaneTag"
					PlaneTag.Value = Plane
					Part.Touched:connect(function(Object)
						if (not Exploded) then
							if (not Object:IsDescendantOf(Character)) and Object.Name ~= "Bomb" then
								Exploded = true
								local Explosion = Instance.new("Explosion")
								Explosion.Position = Part.Position
								Explosion.BlastPressure = 500000
								Explosion.BlastRadius = 75
								ScanPlayers(Part.Position,75)
								Explosion.Parent = game.Workspace
								Part:Destroy()
							end
						end
					end)
					Part.Parent = game.Workspace
					Part.CFrame = (v.CFrame * CFrame.Angles(math.rad(90),0,0)) + v.CFrame.lookVector * 3
					Part.Velocity = (Part.CFrame.lookVector * (TrueAirSpeed * 0.75))
					delay(7,function() Part:Destroy() end)
				end
			end
		end
	end
end

function DropGuidedBomb(Gun) --This function creates guided bombs for the bombs spawns
	if Locked then
		local Exploded = false
		local Part = Instance.new("Part")
		Part.Name = "Bomb"
		Part.CanCollide = false
		Part.FormFactor = "Symmetric"
		Part.Size = Vector3.new(2,2,9)
		Part.BottomSurface = "Smooth"
		Part.TopSurface = "Smooth"
		local Mesh = Instance.new("SpecialMesh")
		Mesh.Parent = Part
		Mesh.MeshId = "http://www.roblox.com/asset/?id=88782666"
		Mesh.MeshType = "FileMesh"
		Mesh.Scale = Vector3.new(4,4,4)
		Mesh.TextureId = "http://www.roblox.com/asset/?id=88782631"
		local OV = Instance.new("ObjectValue")
		OV.Parent = Part
		OV.Name = "Tracker"
		OV.Value = TargetPlayer.Character.Torso
		local NV = Instance.new("NumberValue")
		NV.Parent = Part
		NV.Name = "PlaneSpd"
		NV.Value = TrueAirSpeed * 0.8 --This makes the bombs travel speed 4/5 of the plane's speed
		local BG = Instance.new("BodyGyro")
		BG.Parent = Part
		BG.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
		BG.P = 2000
		local BV = Instance.new("BodyVelocity")
		BV.Parent = Part
		BV.maxForce = Vector3.new(math.huge,6000,math.huge)
		BV.velocity = Vector3.new(0,0,0)
		local Script = BombM:clone()
		Script.Parent = Part
		local PlaneTag = Instance.new("ObjectValue")
		PlaneTag.Parent = Part
		PlaneTag.Name = "PlaneTag"
		PlaneTag.Value = Plane
		Part.Touched:connect(function(Object)
			if (not Exploded) then
				if (not Object:IsDescendantOf(Character)) and Object.Name ~= "Bomb" then
					Exploded = true
					local Explosion = Instance.new("Explosion")
					Explosion.Position = Part.Position
					Explosion.BlastPressure = 500000
					Explosion.BlastRadius = 75
					ScanPlayers(Part.Position,75)
					Explosion.Parent = game.Workspace
					Part:Destroy()
				end
			end
		end)
		Part.Parent = game.Workspace
		Part.CFrame = (Gun.CFrame * CFrame.Angles(math.rad(90),0,0)) + Gun.CFrame.lookVector * 10
		Script.Disabled = false
	end
end

function FireMissile(Gun) --This function creates the non-guided missiles for the missile spawns
	if (not Locked) then
		local Exploded = false
		local Part1 = Instance.new("Part")
		Part1.Name = "Missile"
		Part1.CanCollide = false
		Part1.FormFactor = "Symmetric"
		Part1.Size = Vector3.new(1,1,13)
		Part1.BottomSurface = "Smooth"
		Part1.TopSurface = "Smooth"
		local Mesh = Instance.new("SpecialMesh")
		Mesh.Parent = Part1
		Mesh.MeshId = "http://www.roblox.com/asset/?id=2251534"
		Mesh.MeshType = "FileMesh"
		Mesh.TextureId = "http://www.roblox.com/asset/?id=2564491"
		local Part2 = Instance.new("Part")
		Part2.Parent = Part1
		Part2.Name = "Visual"
		Part2.Transparency = 1
		Part2.CanCollide = false
		Part2.FormFactor = "Symmetric"
		Part2.Size = Vector3.new(1,1,1)
		Part2.BottomSurface = "Smooth"
		Part2.TopSurface = "Smooth"
		local Weld = Instance.new("Weld")
		Weld.Parent = Part1
		Weld.Part0 = Part1
		Weld.Part1 = Part2
		Weld.C0 = CFrame.new(0,0,5)*CFrame.Angles(math.rad(90),0,0)
		local BV = Instance.new("BodyVelocity")
		BV.Parent = Part1
		BV.maxForce = Vector3.new(math.huge,math.huge,math.huge)
		local BG = Instance.new("BodyGyro")
		BG.Parent = Part
		BG.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
		BG.cframe = Gun.CFrame * CFrame.Angles(math.rad(90),0,0)
		local Fire = Instance.new("Fire")
		Fire.Parent = Part2
		Fire.Enabled = false
		Fire.Heat = 25
		Fire.Size = 30
		local Smoke = Instance.new("Smoke")
		Smoke.Parent = Part2
		Smoke.Color = Color3.new(40/51,40/51,40/51)
		Smoke.Enabled = false
		Smoke.Opacity = 1
		Smoke.RiseVelocity = 25
		Smoke.Size = 25
		local PlaneTag = Instance.new("ObjectValue")
		PlaneTag.Parent = Part
		PlaneTag.Name = "PlaneTag"
		PlaneTag.Value = Plane
		Part1.Touched:connect(function(Object)
			if (not Exploded) then
				if (not Object:IsDescendantOf(Character)) and Object.Name ~= "Missile" then
					Exploded = true
					local Explosion = Instance.new("Explosion")
					Explosion.Position = Part1.Position
					Explosion.BlastPressure = 50000
					Explosion.BlastRadius = 50
					ScanPlayers(Part1.Position,50)
					Explosion.Parent = game.Workspace
					Part1:Destroy()
				end
			end
		end)
		Part1.Parent = game.Workspace
		Part1.CFrame = (Gun.CFrame * CFrame.Angles(math.rad(90),0,0)) + Gun.CFrame.lookVector * 15
		BV.velocity = Part1.CFrame.lookVector * Engine.Velocity.magnitude
		delay(0.3,function()
			BV.velocity = (Part1.CFrame.lookVector * 1500) + Vector3.new(0,0.15,0)
			Fire.Enabled = true
			Smoke.Enabled = true
		end)
		delay(5,function() Part1:Destroy() end)
	end
end

function FireGuidedMissile(Gun) --This function creates the guided missiles for the missile spawns
	if Targetable2 then
		if Locked then
			local Exploded = false
			local Part1 = Instance.new("Part")
			Part1.Name = "Missile"
			Part1.CanCollide = false
			Part1.FormFactor = "Symmetric"
			Part1.Size = Vector3.new(1,1,13)
			Part1.BottomSurface = "Smooth"
			Part1.TopSurface = "Smooth"
			local Mesh = Instance.new("SpecialMesh")
			Mesh.Parent = Part1
			Mesh.MeshId = "http://www.roblox.com/asset/?id=2251534"
			Mesh.MeshType = "FileMesh"
			Mesh.TextureId = "http://www.roblox.com/asset/?id=2564491"
			local Part2 = Instance.new("Part")
			Part2.Parent = Part1
			Part2.Transparency = 1
			Part2.Name = "Visual"
			Part2.CanCollide = false
			Part2.FormFactor = "Symmetric"
			Part2.Size = Vector3.new(1,1,1)
			Part2.BottomSurface = "Smooth"
			Part2.TopSurface = "Smooth"
			local Weld = Instance.new("Weld")
			Weld.Parent = Part1
			Weld.Part0 = Part1
			Weld.Part1 = Part2
			Weld.C0 = CFrame.new(0,0,5)*CFrame.Angles(math.rad(90),0,0)
			local OV = Instance.new("ObjectValue")
			OV.Parent = Part1
			OV.Name = "Tracker"
			OV.Value = TargetPlayer.Character.Torso
			local BV = Instance.new("BodyVelocity")
			BV.Parent = Part1
			BV.maxForce = Vector3.new(math.huge,math.huge,math.huge)
			local Script = MissileM:clone()
			Script.Parent = Part1
			local Fire = Instance.new("Fire")
			Fire.Parent = Part2
			Fire.Enabled = false
			Fire.Heat = 25
			Fire.Size = 30
			local Smoke = Instance.new("Smoke")
			Smoke.Parent = Part2
			Smoke.Color = Color3.new(40/51,40/51,40/51)
			Smoke.Enabled = false
			Smoke.Opacity = 1
			Smoke.RiseVelocity = 25
			Smoke.Size = 25
			local PlaneTag = Instance.new("ObjectValue")
			PlaneTag.Parent = Part
			PlaneTag.Name = "PlaneTag"
			PlaneTag.Value = Plane
			Part1.Touched:connect(function(Object)
				if (not Exploded) then
					if (not Object:IsDescendantOf(Character)) and Object.Name ~= "Missile" then
						Exploded = true
						local Explosion = Instance.new("Explosion")
						Explosion.Position = Part1.Position
						Explosion.BlastPressure = 50000
						Explosion.BlastRadius = 50
						ScanPlayers(Part1.Position,50)
						Explosion.Parent = game.Workspace
						Part1:Destroy()
					end
				end
			end)
			Part1.Parent = game.Workspace
			Part1.CFrame = (Gun.CFrame * CFrame.Angles(math.rad(90),0,0)) + Gun.CFrame.lookVector * 15
			delay(0.3,function()
				Script.Disabled = false
				Fire.Enabled = true
				Smoke.Enabled = true
			end)
			delay(10,function() Part1:Destroy() end)
		end
	end
end

function ScanPlayers(Pos,Radius) --This is a function that I created that efficiently puts a CreatorTag in the player
	coroutine.resume(coroutine.create(function()
		for i,v in pairs(game.Players:GetPlayers()) do --This gets all the players
			if v.Character and v.Character:findFirstChild("Torso") then
				local PTorso = v.Character.Torso
				if ((PTorso.Position - Pos).magnitude + 2) <= Radius then --If the distance between the explosion and the player is less than the radius...
					local HitHumanoid = v.Character:findFirstChild("Humanoid")
					if HitHumanoid then
						local CreatorTag = Instance.new("ObjectValue")
						CreatorTag.Name = "creator"
						CreatorTag.Value = Player
						CreatorTag.Parent = HitHumanoid
						game:GetService("Debris"):AddItem(CreatorTag,0.1)
					end
				end
			end
		end
	end))
end

function ReloadRocket(Time) --This function reloads the rockets based on the rocket reload time
	if (not RocketEnabled) then
		wait(Time)
		RocketEnabled = true
	end
end

function ReloadFlare(Time) --This function reloads the flares based on the flare reload time
	if (not FlareEnabled) then
		wait(Time)
		FlareEnabled = true
	end
end

function ReloadBomb(Time) --This function reloads the bombs based on the bomb reload time
	if (not BombEnabled) then
		wait(Time)
		BombEnabled = true
	end
end

function ReloadMissile(Time) --This function reloads the missile based on the missile reload time
	if (not MissileEnabled) then
		wait(Time)
		MissileEnabled = true
	end
end

function onMouseMoved(mouse) --This function is activated when the mouse moves
	if Targetable2 then --If the plane can target...
		local Gui = GuiClone.Main
		if Targeting then
			mouse.Icon = AimingCursor --All the cursors in this script were made by me
			Gui.Mode.Text = "Targeting Mode"
			local FoundPlayer = false
			for i,v in pairs(game.Players:GetPlayers()) do
				if v.Character then
					if v.Character:findFirstChild("Torso") then
						if v ~= Player then
							if ((v.TeamColor ~= Player.TeamColor) or v.Neutral) then
								local myHead = Character.Head
								local TorsoPos = v.Character.Torso.CFrame
								local Distance = (myHead.CFrame.p - TorsoPos.p).magnitude
								local MouseDirection = (mouse.Hit.p - myHead.CFrame.p).unit
								local Offset = (((MouseDirection * Distance) + myHead.CFrame.p) - TorsoPos.p).magnitude
								if (not Locked) then
									if (Offset/Distance) < 0.1 then
										FoundPlayer = true
										if TargetPlayer ~= v then
											TargetPlayer = v
											mouse.Icon = TargetCursor
											AimGui.Enabled = true
											LockGui.Enabled = false
											AimGui.Adornee = TargetPlayer.Character.Torso
											LockGui.Adornee = nil
										end
									end
									if (not FoundPlayer) and TargetPlayer then
										TargetPlayer = nil
										mouse.Icon = AimingCursor
										AimGui.Enabled = false
										LockGui.Enabled = false
										AimGui.Adornee = nil
										LockGui.Adornee = nil
									end
								elseif Locked then
									mouse.Icon = LockedCursor
									AimGui.Enabled = false
									LockGui.Enabled = true
									AimGui.Adornee = nil
									LockGui.Adornee = TargetPlayer.Character.Torso
								end
							end
						end
					end
				end
			end
		elseif (not Targeting) then
			mouse.Icon = NormalCursor
			Gui.Mode.Text = "Flying Mode"
		end
	end
end

function onButton1Down(mouse) --This function is activated when you press the left mouse button
	Locked = ((not Locked) and TargetPlayer and Targeting and EngineOn and Targeting2)
end

function IncreaseSpd() --This function increases the speed
	if EngineOn then
		if Selected then
			while Accelerating do
				Throttle = (Throttle < 1 and Throttle + 0.01 or 1)
				DesiredSpeed = MaxSpeed2 * Throttle
				wait(ThrottleInc2)
			end
		end
	end
end

function DecreaseSpd() --This function decreases the speed
	if EngineOn then
		if Selected then
			while Decelerating do
				Throttle = (Throttle > 0 and Throttle - 0.01 or 0)
				DesiredSpeed = MaxSpeed2 * Throttle
				wait(ThrottleInc2)
			end
		end
	end
end

function RoundNumber(Num) --This function rounds a number to the nearest whole number
	return ((Num - math.floor(Num)) >= 0.5 and math.ceil(Num) or math.floor(Num))
end

function GetGear(Parent) --This function gets all the parts in the Gear folder
	for i,v in pairs(Parent:GetChildren()) do
		if (v:IsA("BasePart")) then
			if (not v:findFirstChild("GearProp")) then
				local GearProp = Instance.new("StringValue")
				GearProp.Name = "GearProp"
				GearProp.Value = v.Transparency..","..tostring(v.CanCollide)
				GearProp.Parent = v
			end
			table.insert(LandingGear,v) --This inserts a table with the gear's properties into the LandingGear table
		end
		GetGear(v)
	end
end

function ChangeGear() --This function extends or retracts the gear
	for i,v in pairs(LandingGear) do
		local GearProp = v.GearProp
		local Comma = GearProp.Value:find(",",1,true)
		local TransVal = tonumber(GearProp.Value:sub(1,Comma - 1))
		local CollideVal = GearProp.Value:sub(Comma + 1)
		v.Transparency = (TransVal ~= 1 and (GearUp and TransVal or 1))
		v.CanCollide = (CollideVal and (GearUp and CollideVal or false))
	end
end

function SetUpGui() --This function sets up the PlaneGui
	local Gui = GuiClone.Main
	Gui.Title.Text = PlaneName2
	local TargetStats = Gui.Parent.Target
	local HUD = Gui.Parent.HUD
	local ControlsA,ControlsB = Gui.ControlsA,Gui.ControlsB
	local FrameA,FrameB = Gui.FrameA,Gui.FrameB
	local C1A,C1B = FrameA.C1.Key,FrameB.C1.Key
	local C2A,C2B = FrameA.C2.Key,FrameB.C2.Key
	local C3A,C3B = FrameA.C3.Key,FrameB.C3.Key
	local C4A,C4B = FrameA.C4.Key,FrameB.C4.Key
	local C5A,C5B = FrameA.C5.Key,FrameB.C5.Key
	local C6,C7 = FrameA.C6.Key,FrameA.C7.Key
	local GearText = Gui.Gear
	for i,v in pairs(LandingGear) do --This section determines whether the gear are up or down
		if v.Transparency == 1 then
			GearUp = true
		else
			GearUp = false
			break
		end
	end
	local MaxSpeedScaled = math.ceil(MaxSpeed2/50)
	for i = 1,(MaxSpeedScaled + 10) do --This creates a loop that clones the SpeedGui and positions it accordingly
		local SpeedGui = HUD.Speed.Main
		local Speed0 = SpeedGui["Speed-0"]
		local SpeedClone = Speed0:clone()
		SpeedClone.Position = UDim2.new(0,0,1,-(80 + (75 * i)))
		SpeedClone.Name = ("Speed-%i"):format(50 * i)
		SpeedClone.Text.Text = tostring(50 * i)
		SpeedClone.Parent = SpeedGui
	end
	local MaxAltScaled = math.ceil(MaxAltitude2/500)
	for i = 1,(MaxAltScaled + 10) do --This creates a loop that clones the AltitudeGui and positions it accordingly
		local AltGui = HUD.Altitude.Main
		local Altitude0 = AltGui["Altitude-0"]
		local AltClone = Altitude0:clone()
		AltClone.Position = UDim2.new(0,0,1,-(80 + (75 * i)))
		AltClone.Name = ("Altitude-%s"):format(tostring(0.5 * i))
		AltClone.Text.Text = tostring(0.5 * i)
		AltClone.Parent = AltGui
	end
	GearText.Text = (GearUp and "Gear Up" or "Gear Down")
	C1A.Text = "Key: "..FlightControls.Engine.Value:upper()
	if FlightControls.SpeedUp.Value == "ArrowKeyUp" then
		C2A.Text = "Key: ArrowKeyUp"
	elseif FlightControls.SpeedUp.Value == "ArrowKeyDown" then
		C2A.Text = "Key: ArrowKeyDown"
	else
		C2A.Text = "Key: "..FlightControls.SpeedUp.Value:upper()
	end
	if FlightControls.SlowDown.Value == "ArrowKeyUp" then
		C3A.Text = "Key: ArrowKeyUp"
	elseif FlightControls.SlowDown.Value == "ArrowKeyDown" then
		C3A.Text = "Key: ArrowKeyDown"
	else
		C3A.Text = "Key: "..FlightControls.SlowDown.Value:upper()
	end
	C4A.Text = "Key: "..FlightControls.Gear.Value:upper()
	if Targetable2 then
		C5A.Text = "Key: "..TargetControls.Modes.Value:upper()
	else
		C5A.Parent.Visible = false
	end
	if Ejectable.Value then
		C6.Text = "Key: "..FlightControls.Eject.Value:upper()
	else
		C6.Parent.Visible = false
	end
	if CamLock.Value then
		C7.Text = "Key: "..FlightControls.LockCam.Value:upper()
	else
		C7.Parent.Visible = false
	end
	if (not WeaponsValue.Value) then
		C1B.Parent.Visible = false
		C2B.Parent.Visible = false
		C3B.Parent.Visible = false
		C4B.Parent.Visible = false
		C5B.Parent.Visible = false
		FrameB.Title.Text = "No Weapons"
	elseif WeaponsValue.Value then
		if WeaponsValue.Missiles.Value then
			C1B.Text = "Key: "..WeaponControls.FireMissile.Value:upper()
		elseif (not WeaponsValue.Missiles.Value) then
			C1B.Parent.Visible = false
		end
		if WeaponsValue.Rockets.Value then
			C2B.Text = "Key: "..WeaponControls.FireRockets.Value:upper()
		elseif (not WeaponsValue.Rockets.Value) then
			C2B.Parent.Visible = false
		end
		if WeaponsValue.Guns.Value then
			C3B.Text = "Key: "..WeaponControls.FireGuns.Value:upper()
		elseif (not WeaponsValue.Guns.Value) then
			C3B.Parent.Visible = false
		end
		if WeaponsValue.Bombs.Value then
			C4B.Text = "Key: "..WeaponControls.DropBombs.Value:upper()
		elseif (not WeaponsValue.Bombs.Value) then
			C4B.Parent.Visible = false
		end
		if WeaponsValue.Flares.Value then
			C5B.Text = "Key: "..WeaponControls.DeployFlares.Value:upper()
		elseif (not WeaponsValue.Flares.Value) then
			C5B.Parent.Visible = false
		end
	end
	ControlsA.MouseButton1Click:connect(function() --This function allows the Flight Controls frame to be opened or closed without an external script
		if GuiAVisible then
			GuiAVisible = false
			FrameA:TweenPosition(UDim2.new(0,150,0,-190),"In","Quad",1,true)
		elseif (not GuiAVisible) then
			GuiAVisible = true
			FrameA:TweenPosition(UDim2.new(0,150,0,170),"Out","Quad",1,true)
		end
	end)
	ControlsB.MouseButton1Click:connect(function()
		if GuiBVisible then
			GuiBVisible = false
			FrameB:TweenPosition(UDim2.new(0,-150,0,-150),"In","Quad",1,true)
		elseif (not GuiBVisible) then
			GuiBVisible = true
			FrameB:TweenPosition(UDim2.new(0,-150,0,170),"Out","Quad",1,true)
		end
	end)
end

function GetRoll(CF) --This function gets the rotation of the Engine. Credit to DevAdrian for this
	local CFRight = CF * CFrame.Angles(0,math.rad(90),0)
	local CFNoRollRight = CFrame.new(CF.p,CF.p + CF.lookVector) * CFrame.Angles(0,math.rad(90),0)
	local CFDiff = CFRight:toObjectSpace(CFNoRollRight)
	return (-math.atan2(CFDiff.lookVector.Y, CFDiff.lookVector.Z) % (math.pi * 2) + math.pi)
end

function GetPitch(CF) --This function gets the pitch of the Engine. Credit to DevAdrian for this
	local LV = CF.lookVector
	local XZDist = math.sqrt(LV.x^2 + LV.z^2)
	return math.atan(LV.y / XZDist)
end

function UpdateCamera() --This function uses the RunService to update the camera. It happens very fast so it is smooth
	if Selected then
		if (not LockedCam) then
			Camera.CameraType = CameraType2
		elseif LockedCam then
			local HeadCF = Character.Head.CFrame
			local PlaneSize = Plane:GetModelSize().magnitude/3
			local Origin = HeadCF.p + (HeadCF.lookVector * (PlaneSize - 1))
			local Target = HeadCF.p + (HeadCF.lookVector * PlaneSize)
			Camera.CameraType = Enum.CameraType.Scriptable
			Camera.CoordinateFrame = CFrame.new(Origin,Target)
			Camera:SetRoll(GetRoll(Character.Head.CFrame))
		end
	else
		Camera.CameraType = Enum.CameraType.Custom
	end
end

function UpdateTargetStats(Target,Gui) --This function updates the stats about the Target
	if Target then
		local myHead = Character.Head
		local TorsoPos = Target.Character.Torso.CFrame
		local Distance = (myHead.CFrame.p - TorsoPos.p).magnitude
		local TargetSpeed = (Target.Character.Torso.Velocity).magnitude
		local TargetAlt = Target.Character.Torso.Position.Y
		Gui.LockName.Text = ("Target: %s"):format(Target.Name)
		Gui.Dist.Text = ("Distance: %s"):format(tostring(math.floor(Distance * 10)/10))
		Gui.Speed.Text = ("Speed: %s"):format(tostring(math.floor(TargetSpeed * 10)/10))
		Gui.Altitude.Text = ("Altitude: %s"):format(tostring(math.floor(TargetAlt * 10)/10))
	elseif (not Target) then
		Gui.LockName.Text = "Target: None"
		Gui.Dist.Text = "Distance: N/A"
		Gui.Speed.Text = "Speed: N/A"
		Gui.Altitude.Text = "Altitude: N/A"
	end
end

function UpdateHUD(Gui) --This function updates the HUD whenever the camera is locked
	Gui.Roll.Rotation = math.deg(GetRoll(Character.Head.CFrame))
	local PitchNum = math.deg(GetPitch(Character.Head.CFrame))/90
	Gui.Roll.Pitch.Position = UDim2.new(0,-200,0,-500 + (PitchNum * 450))
	local SpeedScaled = TrueAirSpeed/50
	Gui.Speed.Main.Position = UDim2.new(0,0,0.5,SpeedScaled * 75)
	Gui.Speed.Disp.Text.Text = RoundNumber(TrueAirSpeed)
	local AltScaled = RoundNumber(Engine.Position.Y)/500
	Gui.Altitude.Main.Position = UDim2.new(0,0,0.5,AltScaled * 75)
	Gui.Altitude.Disp.Text.Text = RoundNumber(Engine.Position.Y)
	local NegFactor = (Engine.Velocity.y/math.abs(Engine.Velocity.y))
	local VerticalSpeed = RoundNumber(math.abs(Engine.Velocity.y))
	Gui.ClimbRate.Text = ("VSI: %i"):format(VerticalSpeed * NegFactor)
	Gui.GearStatus.Text = (GearUp and "Gear Up" or "Gear Down")
	Gui.GearStatus.TextColor3 = (GearUp and Color3.new(0,1,0) or Color3.new(1,0,0))
	Gui.EngineStatus.Text = (EngineOn and "Engine On" or "Engine Off")
	Gui.EngineStatus.TextColor3 = (EngineOn and Color3.new(0,1,0) or Color3.new(1,0,0))
	Gui.StallWarn.Visible = ((not Taxi()) and Stall())
	Gui.PullUp.Visible = (EngineOn and (not Taxi()) and (AltRestrict.Value) and (Engine.Position.Y < (MinAltitude2 + 20)))
	Gui.TaxiStatus.Visible = (Engine and Taxi())
	Gui.Throttle.Bar.Tray.Position = UDim2.new(0,0,1,-(Throttle * 460))
	Gui.Throttle.Bar.Tray.Size = UDim2.new(1,0,0,(Throttle * 460))
	Gui.Throttle.Disp.Text = math.abs(math.floor(Throttle * 100)).."%"
	local StallLinePos = (StallSpeed2/math.floor(TrueAirSpeed + 0.5)) * (StallSpeed2/MaxSpeed2)
	local StallLinePosFix = (StallLinePos > 1 and 1 or StallLinePos < 0 and 0 or StallLinePos)
	Gui.Throttle.Bar.StallLine.Position = UDim2.new(0,0,1 - StallLinePosFix,0)
	Gui.Throttle.Bar.Tray.BackgroundColor3 = (Throttle <= StallLinePosFix and Color3.new(1,0,0) or Color3.new(0,1,0))
end

function UpdateGui(Taxiing,Stalling) --This function updates the gui.
	local Gui = GuiClone.Main
	local TargetStats = GuiClone.Target
	local HUD = Player.PlayerGui.PlaneGui.HUD
	Gui.Visible = ((not HUDOnLock.Value) or (HUDOnLock.Value and (not LockedCam)))
	HUD.Visible = (LockedCam and HUDOnLock.Value)
	if LockedCam and HUDOnLock.Value then UpdateHUD(HUD) end
	if Targetable2 then UpdateTargetStats(TargetPlayer,TargetStats) end
	Gui.PullUp.Visible = (EngineOn and (not Taxiing) and (AltRestrict.Value) and (Engine.Position.Y < (MinAltitude2 + 20)))
	Gui.Taxi.Visible = (EngineOn and Taxiing)
	Gui.Stall.Visible = ((not Taxiing) and Stalling)
	Gui.Altitude.Text = "Altitude: "..RoundNumber(Engine.Position.Y)
	Gui.Speed.Text = "Speed: "..RoundNumber(TrueAirSpeed)
	Gui.Throttle.Bar.Tray.Size = UDim2.new(Throttle,0,1,0)
	Gui.Throttle.Percent.Text = math.abs(math.floor(Throttle * 100)).."%"
	local StallLinePos = (StallSpeed2/math.floor(TrueAirSpeed + 0.5)) * (StallSpeed2/MaxSpeed2)
	local StallLinePosFix = (StallLinePos > 1 and 1 or StallLinePos < 0 and 0 or StallLinePos)
	Gui.Throttle.Bar.StallLine.Position = UDim2.new(StallLinePosFix,0,0,0)
	Gui.Throttle.Bar.Tray.BackgroundColor3 = (Throttle <= StallLinePosFix and Color3.new(1,0,0) or Color3.new(0,2/3,0))
end

function CalculateSpeed() --This function calculates the current speed
	while Selected do
		if EngineOn then
			CurrentSpeed = (CurrentSpeed < DesiredSpeed and CurrentSpeed + 2 or CurrentSpeed - 2) --A simple ternary operation that calculates the currentspeed
			CurrentSpeed = (CurrentSpeed < 0 and 0 or CurrentSpeed > MaxSpeed2 and MaxSpeed2 or CurrentSpeed) --This fixes the currentspeed
		end
		wait(0.5 - (Acceleration2/2000))
	end
end

function GetLowestPoint() --This function gets the lowest point of the plane
	if (#LandingGear == 0) then
		LowestPoint = (Engine.Position.Y + 5 + (Engine.Size.Y/2))
		return
	end
	for i,v in pairs(LandingGear) do
		local Set0 = (Engine.Position.Y - (v.CFrame * CFrame.new((v.Size.X/2),0,0)).Y)
		local Set1 = (Engine.Position.Y - (v.CFrame * CFrame.new(-(v.Size.X/2),0,0)).Y)
		local Set2 = (Engine.Position.Y - (v.CFrame * CFrame.new(0,(v.Size.Y/2),0)).Y)
		local Set3 = (Engine.Position.Y - (v.CFrame * CFrame.new(0,-(v.Size.Y/2),0)).Y)
		local Set4 = (Engine.Position.Y - (v.CFrame * CFrame.new(0,0,(v.Size.Z/2))).Y)
		local Set5 = (Engine.Position.Y - (v.CFrame * CFrame.new(0,0,-(v.Size.Z/2))).Y)
		local Max = (math.max(Set0,Set1,Set2,Set3,Set4,Set5) + 5)
		LowestPoint = (Max > LowestPoint and Max or LowestPoint)
	end
end

function GetBankAngle(M) --This function calculates the Bank Angle
	local VSX,X = M.ViewSizeX,M.X
	local Ratio = (((VSX/2) - X)/(VSX/2))
	Ratio = (Ratio < -1 and -1 or Ratio > 1 and 1 or Ratio)
	return math.rad(Ratio * MaxBank2)
end

function Taxi() --This function determines whether the plane is taxiing or not
	local Ray = Ray.new(Engine.Position,Vector3.new(0,-LowestPoint,0))
	return (TrueAirSpeed <= StallSpeed2 and game.Workspace:FindPartOnRay(Ray,Plane))
end

function Stall() --This function determines whether the plane is stalling or not
	return ((AltRestrict.Value and Engine.Position.Y > MaxAltitude2) or TrueAirSpeed < StallSpeed2)
end

function FlyMain(M) --This is the main flying function
	if Selected then
		local BankAngle = GetBankAngle(M) --This uses the "GetBankAngle" function to calculate the Bank Angle
		local Taxi,Stall = Taxi(),Stall()
		if EngineOn then
			Engine.Thrust.velocity = (Engine.CFrame.lookVector * CurrentSpeed) + Vector3.new(0,0.15,0)
			if Taxi then
				if (CurrentSpeed < 2) then
					Thrust.maxForce = Vector3.new(0,0,0)
					Direction.maxTorque = Vector3.new(0,0,0)
				else
					Thrust.maxForce = Vector3.new(math.huge,0,math.huge)
					Direction.maxTorque = Vector3.new(0,math.huge,0)
					Direction.cframe = CFrame.new(Engine.Position,M.Hit.p)
				end
			elseif Stall then
				Thrust.maxForce = Vector3.new(0,0,0)
				Direction.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
				Direction.cframe = (M.Hit*CFrame.Angles(0,0,BankAngle))
			else
				Thrust.maxForce = Vector3.new(math.huge,math.huge,math.huge)
				Direction.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
				Direction.cframe = (M.Hit*CFrame.Angles(0,0,BankAngle))
			end
			if ((AltRestrict.Value) and (Engine.Position.Y < MinAltitude2)) then --If there are altitude restrictions and you are below it...
				AutoCrash.Value = true
			end
		elseif (not EngineOn) then
			Thrust.maxForce = Vector3.new(0,0,0)
			Thrust.velocity = Vector3.new(0,0,0)
			Direction.maxTorque = Vector3.new(0,0,0)
		end
		TrueAirSpeed = Engine.Velocity.magnitude
		UpdateGui(Taxi,Stall) --This activates the "UpdateGui" function]]
		wait()
	end
end

function onKeyDown(Key) --This function is activated whenever a key is pressed
	Key:lower()
	if (Key == FlightControls.Engine.Value) then --If you press the engine key...
		local Gui = GuiClone.Main
		if (not EngineOn) then
			EngineOn = true
			DesiredSpeed = 0
			CurrentSpeed = 0
			Throttle = 0
			Gui.Engine.Visible = false
			CalculateSpeed()
		elseif EngineOn then
			EngineOn = false
			DesiredSpeed = 0
			CurrentSpeed = 0
			Throttle = 0
			Gui.Engine.Visible = true
		end
	end
	if (Key == FlightControls.Gear.Value) then --If you press the change gear key...
		local Gui = GuiClone.Main
		local Taxiing = Taxi()
		if (#LandingGear ~= 0) then
			if (not Taxiing) then
				ChangeGear()
				if (not GearUp) then
					GearUp = true
					Gui.Gear.Text = "Gear Up"
				elseif GearUp then
					GearUp = false
					Gui.Gear.Text = "Gear Down"
				end
			end
		end
	end
	if SUAK and Key:byte() == SpeedUp2 or (not SUAK) and (Key == SpeedUp2) then --If you press the speed up key...
		Accelerating = true
		IncreaseSpd()
	end
	if SDAK and Key:byte() == SlowDown2 or (not SDAK) and (Key == SlowDown2) then --If you press the slow down key...
		Decelerating = true
		DecreaseSpd()
	end
	if (Key == TargetControls.Modes.Value) then --If you press the change modes key...
		if Targetable2 then
			if EngineOn then
				if (not Targeting) then
					Targeting = true
				elseif Targeting then
					Targeting = false
					Locked = false
					AimGui.Enabled = false
					LockGui.Enabled = false
				end
			end
		end
	end
	if (Key == FlightControls.Eject.Value:lower()) then
		if EngineOn then
			local Taxiing = Taxi()
			if (not Taxiing) then
				if Ejectable.Value then
					if (not Plane.Ejected.Value) then
						Plane.Ejected.Value = true
						local Seat = MainParts.Seat
						local EjectClone = Tool.Ejector:clone()
						EjectClone.Parent = Player.PlayerGui
						EjectClone.Disabled = false
						local Fire = Instance.new("Fire")
						Fire.Parent = Engine
						Fire.Heat = 25
						Fire.Size = 30
						local Smoke = Instance.new("Smoke")
						Smoke.Parent = Engine
						Smoke.Color = Color3.new(1/3,1/3,1/3)
						Smoke.Opacity = 0.7
						Smoke.RiseVelocity = 10
						Smoke.Size = 10
						Seat.SeatWeld:remove()
					end
				end
			end
		end
	end
	if (Key == FlightControls.LockCam.Value) then
		LockedCam = (not LockedCam)
	end
	if (Key == WeaponControls.FireGuns.Value) then --If you press the fire guns key...
		if WeaponsValue.Value then --If there are weapons...
			if WeaponsValue.Guns.Value then --If there are guns...
				if EngineOn then
					local Taxiing = Taxi()
					if (not Taxiing) then --This prevents you from firing the gun while your on the ground
						FiringGun = true
						FireMachineGun(Weapons) --This activates the "FireMachineGun" function
					end
				end
			end
		end
	end
	if (Key == WeaponControls.FireRockets.Value) then --If you press the fire rockets key...
		if WeaponsValue.Value then
			if WeaponsValue.Rockets.Value then
				local Taxiing = Taxi()
				if (not Taxiing) then
					if RocketEnabled then
						RocketEnabled = false
						FireRockets(Weapons)
						ReloadRocket(RocketTime2)
					end
				end
			end
		end
	end
	if (Key == WeaponControls.DeployFlares.Value) then --If you press the deploy flares key...
		if WeaponsValue.Value then
			if WeaponsValue.Flares.Value then
				if EngineOn then
					local Taxiing = Taxi()
					if (not Taxiing) then
						if FlareEnabled then --This makes the plane deploy flares 5 times every 0.2 seconds before you have to reload
							FlareEnabled = false
							for i = 1,5 do
								DeployFlares(Weapons)
								wait(0.2)
							end
							ReloadFlare(FlareTime2)
						end
					end
				end
			end
		end
	end
	if (Key == WeaponControls.DropBombs.Value) then --If you press the drop bombs key...
		if WeaponsValue.Value then
			if WeaponsValue.Bombs.Value then
				if EngineOn then
					local Taxiing = Taxi()
					if (not Taxiing) then
						if BombEnabled then
							BombEnabled = false
							local BombSpawns = {}
							for i,v in pairs(Weapons:GetChildren()) do
								if v:IsA("BasePart") then
									if v.Name == "BombSpawn" then
										table.insert(BombSpawns,v)
									end
								end
							end
							local CurrentSpawn = BombSpawns[math.random(1,#BombSpawns)] --This line selects a random bomb spawn
							if Locked then
								DropGuidedBomb(CurrentSpawn)
								ReloadBomb((BombTime2 * 2))
							elseif (not Locked) then
								for i = 1,5 do
									DropBomb(Weapons)
									wait(0.3)
								end
								ReloadBomb(BombTime2)
							end
						end
					end
				end
			end
		end
	end
	if (Key == WeaponControls.FireMissile.Value) then --If you press the fire missile key...
		if WeaponsValue.Value then
			if WeaponsValue.Missiles.Value then
				if EngineOn then
					local Taxiing = Taxi()
					if (not Taxiing) then
						if MissileEnabled then
							MissileEnabled = false
							local MissileSpawns = {}
							for i,v in pairs(Weapons:GetChildren()) do
								if v:IsA("BasePart") then
									if v.Name == "MissileSpawn" then
										table.insert(MissileSpawns,v)
									end
								end
							end
							local CurrentSpawn = MissileSpawns[math.random(1,#MissileSpawns)] --This line selects a random missile spawn
							if Locked then
								FireGuidedMissile(CurrentSpawn)
								ReloadMissile((MissileTime2 * 2))
							elseif (not Locked) then
								FireMissile(CurrentSpawn)
								ReloadMissile(MissileTime2)
							end
						end
					end
				end
			end
		end
	end
	if (Key == TargetControls.UnTarget.Value) then --If you press the untarget key...
		if Targetable2 then
			if Locked then
				Locked = false
			end
		end
	end
end

function onKeyUp(Key) --This function is activated when you let go of a key
	Key:lower()
	if SUAK and Key:byte() == SpeedUp2 or (not SUAK) and (Key == SpeedUp2) then --If you let go of the speed up key...
		Accelerating = false
	end
	if SDAK and Key:byte() == SlowDown2 or (not SDAK) and (Key == SlowDown2) then --If you let go of the slow down key...
		Decelerating = false
	end
	if (Key == WeaponControls.FireGuns.Value) then --If you let go of the fire guns key...
		FiringGun = false
	end
end

function onSelected(mouse) --This function is activated when you select the Plane tool
	Selected = true
	mouse2 = mouse
	FixVars() --This activates the "FixVars" function
	GetGear(Gear) --This activates the "GetGear" function
	GetLowestPoint() --This activates the "GetLowestPoint" function
	ToolSelect.Value = true
	GuiClone = GUI:clone() --This line and the next one clones the plane gui and puts it into the player
	GuiClone.Parent = Player.PlayerGui
	SetUpGui() --This activates the "SetUpGui" function
	Camera.CameraType = CameraType2 --This makes your cameratype the customize cameratype
	if Targetable2 then --If the plane can target, then it will create the objects required for targeting
		AimGui = Instance.new("BillboardGui",Player.PlayerGui)
		AimGui.AlwaysOnTop = true
		AimGui.Enabled = false
		AimGui.Size = UDim2.new(0,50,0,50)
		local Label = Instance.new("ImageLabel",AimGui)
		Label.BackgroundTransparency = 1
		Label.Image = "http://www.roblox.com/asset/?id=107388694"
		Label.Size = UDim2.new(1,0,1,0)
		LockGui = Instance.new("BillboardGui",Player.PlayerGui)
		LockGui.AlwaysOnTop = true
		LockGui.Enabled = false
		LockGui.Size = UDim2.new(0,50,0,50)
		local Label = Instance.new("ImageLabel",LockGui)
		Label.BackgroundTransparency = 1
		Label.Image = "http://www.roblox.com/asset/?id=107388656"
		Label.Size = UDim2.new(1,0,1,0)
	end
	mouse.Icon = NormalCursor
	FTab[1] = mouse.Move:connect(function() onMouseMoved(mouse) end) --Lines 1025-1029 activate the given functions
	FTab[2] = mouse.Idle:connect(function() onMouseMoved(mouse) end)
	FTab[3] = mouse.Button1Down:connect(function() onButton1Down(mouse) end)
	FTab[4] = mouse.KeyDown:connect(onKeyDown)
	FTab[5] = mouse.KeyUp:connect(onKeyUp)
	FTab[6] = RunService.RenderStepped:connect(UpdateCamera)
	FTab[7] = RunService.Stepped:connect(function() FlyMain(mouse) end)
end

function onDeselected(mouse) --This function is activated when you deselect the Plane tool
	Selected = false
	LockedCam = false
	for i,v in pairs(FTab) do --This disconnects all the connections. It prevents bugs
		if v then
			v:disconnect()
		end
	end
	Camera.CameraType = Enum.CameraType.Custom --This makes the CameraType "Custom"
	Camera.CameraSubject = Character.Humanoid
	if Targetable2 then --If the plane can target, then the objects required for targeting will be removed
		AimGui:remove()
		LockGui:remove()
	end
	if (not Taxi()) and EngineOn then --If you're not Taxiing and your engine is on...
		if (not Deselect0.Value) and (not Plane.Ejected.Value) then --If you deselected the tool and didn't eject...
			onDeselectFlying()
		end
	end
	CurrentSpeed = 0 --Lines 1041-1054 resets the plane, the plane gui, and the plane tool
	DesiredSpeed = 0
	TrueAirSpeed = 0
	EngineOn = false
	Updating = false
	Locked = false
	Targeting = false
	TargetPlayer = nil
	ToolSelect.Value = false
	GuiAVisible = true
	GuiBVisible = true
	GuiClone:remove()
	Engine.Thrust.velocity = Vector3.new(0,0,0)
	Engine.Thrust.maxForce = Vector3.new(0,0,0)
	Engine.Direction.maxTorque = Vector3.new(0,0,0)
end

function onDeselectFlying() --This function blows up the plane
	if (not Deselect0.Value) then
		local Explosion = Instance.new("Explosion")
		Explosion.Parent = game.Workspace
		Explosion.Position = Engine.Position
		Explosion.BlastRadius = Plane:GetModelSize().magnitude
		Explosion.BlastPressure = 100000
		Character.Humanoid.Health = 0
		Engine.Thrust:remove()
		Engine.Direction:remove()
		delay(5,function()
			Plane:Destroy()
		end)
	end
end

function onDeselectForced() --This function is activated when you get out of the plane without deselecting the tool first
	if Deselect0.Value then
		onDeselected()
		mouse2.Icon = "rbxasset://textures\\ArrowCursor.png" --This makes the mouse icon the normal icon
	end
end

script.Parent.Selected:connect(onSelected) --The next 3 lines activate the given functions
script.Parent.Deselected:connect(onDeselected)
Deselect0.Changed:connect(onDeselectForced)


Prompt: --[[ The Module ]]

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

function Poppercam.new()
	local self = setmetatable(BaseOcclusion.new(), Poppercam)

	self.camera = nil
	self.cameraSubjectChangeConn = nil

	self.subjectPart = nil

	self.playerCharacters = {} 	-- For ignoring in raycasts
	self.vehicleParts = {} 		-- Also just for ignoring

	self.lastPopAmount = 0
	self.lastZoomLevel = 0
	self.popperEnabled = false

	return self
end

function Poppercam:GetOcclusionMode()
	return Enum.DevCameraOcclusionMode.Zoom
end

function Poppercam:Enable(enable)

end


Prompt:
-- ================================================================================
-- Settings
-- ================================================================================

Response:
local Settings = {}

Settings.DefaultSpeed = 150		-- Speed when not boosted [Studs/second, Range 50-300]
Settings.BoostSpeed = 200		-- Speed when boosted [Studs/second, Maximum: 400]
Settings.BoostAmount = 10		-- Duration of boost in seconds
Settings.Steering = 5			-- How quickly the speeder turns [Range: 1-10]


Prompt: --[[Engine (Avxnturador)]]

Response:
	-- Everything below can be illustrated and tuned with the graph below.
	-- https://www.desmos.com/calculator/oishj9m1tq
	-- This includes everything, from the engines, to boost, to electric.

	-- To import engines prior to AC6C V1.3, consult the README.

	-- Naturally Aspirated Engine
	Tune.Engine 		= true

		Tune.Horsepower		= 970
		Tune.IdleRPM		= 750
		Tune.PeakRPM		= 6800
		Tune.Redline		= 8000
		Tune.EqPoint		= 5252
		Tune.PeakSharpness	= 10
		Tune.CurveMult		= 0.4

	-- Electric Engine
	Tune.Electric		= true

		Tune.E_Redline	= 12700
		Tune.E_Trans1	= 4000
		Tune.E_Trans2	= 7000
		-- Horsepower
		Tune.E_Horsepower	= 223
		Tune.EH_FrontMult	= 0.15
		Tune.EH_EndMult		= 2.9
		Tune.EH_EndPercent	= 7
		-- Torque
		Tune.E_Torque		= 286
		Tune.ET_EndMult		= 1.505
		Tune.ET_EndPercent	= 27.5

	-- Turbocharger
	Tune.Turbochargers	= 2				-- Number of turbochargers in the engine
										-- Set to 0 for no turbochargers
		Tune.T_Boost		= 25
		Tune.T_Efficiency	= 8.5

		Tune.T_Size			= 80		-- Turbo Size; Bigger size = more turbo lag

	-- Supercharger
	Tune.Superchargers	= 0				-- Number of superchargers in the engine
										-- Set to 0 for no superchargers
		Tune.S_Boost		= 7
		Tune.S_Efficiency	= 8.5

		Tune.S_Sensitivity	= 0.05		-- Supercharger responsiveness/sensitivity, applied per tick (recommended values between 0.05 to 0.1)

	--Misc
	Tune.ThrotAccel		= .05		-- Throttle acceleration, applied per tick (recommended values between 0.05 to 0.1)
	Tune.ThrotDecel		= .2		-- Throttle deceleration, applied per tick (recommended values between 0.1 to 0.3)

	Tune.BrakeAccel		= .2		-- Brake acceleration, applied per tick
	Tune.BrakeDecel		= .5		-- Brake deceleration, applied per tick

	Tune.RevAccel		= 250		-- 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.Flywheel		= 500		-- Flywheel weight (higher = faster response, lower = more stable RPM)

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


Prompt: ------ Programmed by BuildIntoGames; Removing this line will kill 5 children


Prompt: --[[[Default Controls]]

Response:
	--Peripheral Deadzones
	Tune.Peripherals = {
		MSteerWidth				= 67		,	-- Mouse steering control width	(0 - 100% of screen width)
		MSteerDZone				= 10		,	-- Mouse steering deadzone (0 - 100%)

		ControlLDZone			= 5			,	-- Controller steering L-deadzone (0 - 100%)
		ControlRDZone			= 5			,	-- Controller steering R-deadzone (0 - 100%)
	}

	--Control Mapping
	Tune.Controls = {

	--Keyboard Controls
		--Mode Toggles
		ToggleABS				= Enum.KeyCode.Y					,
		ToggleTransMode			= Enum.KeyCode.Q					,
		--Primary Controls
		Throttle				= Enum.KeyCode.Up					,
		Brake					= Enum.KeyCode.Down					,
		SteerLeft				= Enum.KeyCode.Left					,
		SteerRight				= Enum.KeyCode.Right				,

		--Secondary Controls
		Throttle2				= Enum.KeyCode.W					,
		Brake2					= Enum.KeyCode.S					,
		SteerLeft2				= Enum.KeyCode.A					,
		SteerRight2				= Enum.KeyCode.D					,

		--Manual Transmission
		ShiftUp					= Enum.KeyCode.E					,
		ShiftDown				= Enum.KeyCode.Q					,
		Clutch					= Enum.KeyCode.LeftShift			,

		--Handbrake
		PBrake					= Enum.KeyCode.P					,

	--Mouse Controls
		MouseThrottle			= Enum.UserInputType.MouseButton1	,
		MouseBrake				= Enum.UserInputType.MouseButton2	,
		MouseClutch				= Enum.KeyCode.W					,
		MouseShiftUp			= Enum.KeyCode.E					,
		MouseShiftDown			= Enum.KeyCode.Q					,
		MousePBrake				= Enum.KeyCode.LeftShift			,

	--Controller Mapping
		ContlrThrottle			= Enum.KeyCode.ButtonR2				,
		ContlrBrake				= Enum.KeyCode.ButtonL2				,
		ContlrSteer				= Enum.KeyCode.Thumbstick1			,
		ContlrShiftUp			= Enum.KeyCode.ButtonY				,
		ContlrShiftDown			= Enum.KeyCode.ButtonX				,
		ContlrClutch			= Enum.KeyCode.ButtonR1				,
		ContlrPBrake			= Enum.KeyCode.ButtonL1				,
		ContlrToggleTMode		= Enum.KeyCode.DPadUp				,
		ContlrToggleTCS			= Enum.KeyCode.DPadDown				,
		ContlrToggleABS			= Enum.KeyCode.DPadRight			,
	}


Prompt: -- A symbol that represents the absence of a value.

Response:
export type None = PubTypes.Symbol & {
	-- name: "None" (add this when Luau supports singleton types)
}


Prompt:
--[=[
	Creates a promise from a signal

	@param signal Signal<T>
	@return Promise<T>
]=]

Response:
function PromiseUtils.fromSignal(signal)
	local promise = Promise.new()
	local conn

	promise:Finally(function()
		conn:Disconnect()
		conn = nil
	end)

	conn = signal:Connect(function(...)
		promise:Resolve(...)
	end)

	return promise
end


Prompt: -- / Configurations / --

Response: local Configuration = Gun.Configuration


Prompt: --------------------------CHARACTER CONTROL-------------------------------

Response:
local CurrentIgnoreList

local function GetCharacter()
	return Player and Player.Character
end

local function GetTorso()
	local humanoid = findPlayerHumanoid(Player)
	return humanoid and humanoid.Torso
end

local function getIgnoreList()
	if CurrentIgnoreList then
		return CurrentIgnoreList
	end
	CurrentIgnoreList = {}
	table.insert(CurrentIgnoreList, GetCharacter())
	return CurrentIgnoreList
end


Prompt: -- Only change the number below! --

Response: local jumpCooldown = 2.0 -- Change this to the cooldown for every jump (decimals accepted)


Prompt: --important stuff to register what is what. you need these if you want to do stuff with the tool itself.

Response:
Tool.Activated:connect(Activated)
Tool.Equipped:connect(Equipped)
Tool.Unequipped:connect(Unequipped)

Handle.Touched:connect(Blow)


Prompt: --------RIGHT DOOR --------

Response:
game.Workspace.doorright.l11.BrickColor = BrickColor.new(game.Workspace.Lighting.secondary.Value)
game.Workspace.doorright.l22.BrickColor = BrickColor.new(game.Workspace.Lighting.secondary.Value)
game.Workspace.doorright.l33.BrickColor = BrickColor.new(game.Workspace.Lighting.secondary.Value)
game.Workspace.doorright.l41.BrickColor = BrickColor.new(game.Workspace.Lighting.secondary.Value)
game.Workspace.doorright.l52.BrickColor = BrickColor.new(game.Workspace.Lighting.secondary.Value)
game.Workspace.doorright.l63.BrickColor = BrickColor.new(game.Workspace.Lighting.secondary.Value)
game.Workspace.doorright.l71.BrickColor = BrickColor.new(game.Workspace.Lighting.secondary.Value)

game.Workspace.doorright.l43.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l61.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l53.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l72.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l62.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l51.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l21.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l31.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l12.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l13.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l32.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l23.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l42.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)
game.Workspace.doorright.l73.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)

game.Workspace.doorright.pillar.BrickColor = BrickColor.new(game.Workspace.Lighting.defaultlights.Value)


Prompt: -- Menus

Response:
function Icon:setMenu(arrayOfIcons)
	-- Reset any previous icons
	for i, otherIcon in pairs(self.menuIcons) do
		otherIcon:leave()
	end
	-- Apply new icons
	if type(arrayOfIcons) == "table" then
		for i, otherIcon in pairs(arrayOfIcons) do
			otherIcon:join(self, "menu", true)
		end
	end
	-- Update menu
	self:_updateMenu()
	return self
end

function Icon:_getMenuDirection()
	local direction = (self:get("menuDirection") or "_NIL"):lower()
	local alignment = (self:get("alignment") or "_NIL"):lower()
	if direction ~= "left" and direction ~= "right" then
		direction = (alignment == "left" and "right") or "left"
	end
	return direction
end

function Icon:_updateMenu()
	local values = {
		maxIconsBeforeScroll = self:get("menuMaxIconsBeforeScroll") or "_NIL",
		direction = self:get("menuDirection") or "_NIL",
		iconAlignment = self:get("alignment") or "_NIL",
		scrollBarThickness = self:get("menuScrollBarThickness") or "_NIL",
	}
	for k, v in pairs(values) do if v == "_NIL" then return end end

	local XPadding = IconController[values.iconAlignment.."Gap"]--12
	local menuContainer = self.instances.menuContainer
	local menuFrame = self.instances.menuFrame
	local menuList = self.instances.menuList
	local totalIcons = #self.menuIcons

	local direction = self:_getMenuDirection()
	local lastVisibleIconIndex = (totalIcons > values.maxIconsBeforeScroll and values.maxIconsBeforeScroll) or totalIcons
	local newCanvasSizeX = -XPadding
	local newFrameSizeX = 0
	local newMinHeight = 0
	local sortFunc = (direction == "right" and function(a,b) return a:get("order") < b:get("order") end) or function(a,b) return a:get("order") > b:get("order") end
	table.sort(self.menuIcons, sortFunc)
	for i = 1, totalIcons do
		local otherIcon = self.menuIcons[i]
		local otherIconSize = otherIcon:get("iconSize")
		local increment = otherIconSize.X.Offset + XPadding
		if i <= lastVisibleIconIndex then
			newFrameSizeX = newFrameSizeX + increment
		end
		if i == lastVisibleIconIndex and i ~= totalIcons then
			newFrameSizeX = newFrameSizeX -2--(increment/4)
		end
		newCanvasSizeX = newCanvasSizeX + increment
		local otherIconHeight = otherIconSize.Y.Offset
		if otherIconHeight > newMinHeight then
			newMinHeight = otherIconHeight
		end
		-- This ensures the menu is navigated fully and correctly with a controller
		local prevIcon = self.menuIcons[i-1]
		local nextIcon = self.menuIcons[i+1]
		otherIcon.instances.iconButton.NextSelectionRight = prevIcon and prevIcon.instances.iconButton
		otherIcon.instances.iconButton.NextSelectionLeft = nextIcon and nextIcon.instances.iconButton
	end

	local canvasSize = (lastVisibleIconIndex == totalIcons and 0) or newCanvasSizeX + XPadding
	self:set("menuCanvasSize", UDim2.new(0, canvasSize, 0, 0))
	self:set("menuSize", UDim2.new(0, newFrameSizeX, 0, newMinHeight + values.scrollBarThickness + 3))

	-- Set direction
	local directionDetails = {
		left = {
			containerAnchorPoint = Vector2.new(1, 0),
			containerPosition = UDim2.new(0, -4, 0, 0),
			canvasPosition = Vector2.new(canvasSize, 0)
		},
		right = {
			containerAnchorPoint = Vector2.new(0, 0),
			containerPosition = UDim2.new(1, XPadding-2, 0, 0),
			canvasPosition = Vector2.new(0, 0),
		}
	}
	local directionDetail = directionDetails[direction]
	menuContainer.AnchorPoint = directionDetail.containerAnchorPoint
	menuContainer.Position = directionDetail.containerPosition
	menuFrame.CanvasPosition = directionDetail.canvasPosition
	self._menuCanvasPos = directionDetail.canvasPosition

	menuList.Padding = UDim.new(0, XPadding)
end

function Icon:_menuIgnoreClipping()
	self:_ignoreClipping("menu")
end


Prompt:
--[[**
		ensures value is an array of a strict makeup and size

		@param check The check to compare all values with

		@returns A function that will return true iff the condition is passed
	**--]]

Response:
	function t.strictArray(...)
		local valueTypes = { ... }
		assert(t.array(t.callback)(valueTypes))

		return function(value)
			local keySuccess, keyErrMsg = arrayKeysCheck(value)
			if keySuccess == false then
				return false, string.format("[strictArray] %s", keyErrMsg or "")
			end

			-- If there's more than the set array size, disallow
			if #valueTypes < #value then
				return false, string.format("[strictArray] Array size exceeds limit of %d", #valueTypes)
			end

			for idx, typeFn in valueTypes do
				local typeSuccess, typeErrMsg = typeFn(value[idx])
				if not typeSuccess then
					return false, string.format("[strictArray] Array index #%d - %s", idx, typeErrMsg)
				end
			end

			return true
		end
	end
end

do
	local callbackArray = t.array(t.callback)


Prompt: --s.Pitch = 0.7

Response:
while s.Pitch<0.6 do
s.Pitch=s.Pitch+0.010
s:Play()
if s.Pitch>0.6 then
	s.Pitch=0.6
end
wait(0.001)
end


Prompt:
--Tool.Equipped:connect(OnEquipped)
--Tool.Changed:connect(OnChanged)

Response:
Tool = script.Parent
mouse = game.Players.LocalPlayer:GetMouse()

colors = {45, 119, 21, 24, 23, 105, 104}

function fire(v)

	script.Parent.fire:FireServer(v)

end

Tool.Enabled = true
function onActivated()

	if not Tool.Enabled then
		return
	end

	Tool.Enabled = false

	local character = Tool.Parent;
	local humanoid = character.Humanoid
	if humanoid == nil then
		print("Humanoid not found")
		return
	end

	local targetPos = humanoid.TargetPoint
	local lookAt = (mouse.Hit.p - character.Head.Position).unit

	fire(lookAt)

	wait(.5)

	Tool.Enabled = true
end

script.Parent.Activated:connect(onActivated)


Prompt: --[[ Initialization ]]

Response:
--
 -- TODO: Remove when safe! ContextActionService crashes touch clients with tupele is 2 or more
if not UserInputService.TouchEnabled then
	initialize()
	if isShiftLockMode() then
		InputCn = UserInputService.InputBegan:connect(onShiftInputBegan)
		IsActionBound = true
	end
end


Prompt: --// Script

Response:
for index,Weapon in pairs(Folder:GetChildren()) do
local Clone = Template:Clone()
Clone.Name = Weapon.Name
Clone.Price.Value = Weapon.Price.Value
Clone.NAME.Text = Weapon.Name
Clone.COST.Text = Weapon.Price.Value
Clone.Parent = script.Parent
Clone.Visible = true
end


Prompt: ----- Private Variables -----

Response:
local ActiveProfileStores = ProfileService._active_profile_stores
local AutoSaveList = ProfileService._auto_save_list
local IssueQueue = ProfileService._issue_queue

local DataStoreService = game:GetService("DataStoreService")
local RunService = game:GetService("RunService")

local PlaceId = game.PlaceId
local JobId = game.JobId

local AutoSaveIndex = 1 -- Next profile to auto save
local LastAutoSave = os.clock()

local LoadIndex = 0

local ActiveProfileLoadJobs = 0 -- Number of active threads that are loading in profiles
local ActiveProfileSaveJobs = 0 -- Number of active threads that are saving profiles

local CriticalStateStart = 0 -- os.clock()

local IsStudio = RunService:IsStudio()
local IsLiveCheckActive = false

local UseMockDataStore = false
local MockDataStore = ProfileService._mock_data_store -- Mock data store used when API access is disabled

local UserMockDataStore = ProfileService._user_mock_data_store -- Separate mock data store accessed via ProfileStore.Mock
local UseMockTag = {}

local CustomWriteQueue = {
	--[[
		[store] = {
			[key] = {
				LastWrite = os.clock(),
				Queue = {callback, ...},
				CleanupJob = nil,
			},
			...
		},
		...
	--]]
}


Prompt: --SFX ID to Sound object

Response:
local Sounds = {}
local SoundService = game:GetService("SoundService")

do
	local Figure = script.Parent.Parent
	Head = Figure:WaitForChild("Head")
	while not Humanoid do
		for _,NewHumanoid in pairs(Figure:GetChildren()) do
			if NewHumanoid:IsA("Humanoid") then
				Humanoid = NewHumanoid
				break
			end
		end
		if Humanoid then break end
		Figure.ChildAdded:wait()
	end
	Sounds[SFX.Died] = 			Head:WaitForChild("Died")
	Sounds[SFX.Running] = 		Head:WaitForChild("Running")
	Sounds[SFX.Swimming] = 	Head:WaitForChild("Swimming")
	Sounds[SFX.Climbing] = 	Head:WaitForChild("Climbing")
	Sounds[SFX.Jumping] = 		Head:WaitForChild("Jumping")
	Sounds[SFX.GettingUp] = 	Head:WaitForChild("GettingUp")
	Sounds[SFX.FreeFalling] = 	Head:WaitForChild("FreeFalling")
	Sounds[SFX.Landing] = 		Head:WaitForChild("Landing")
	Sounds[SFX.Splash] = 		Head:WaitForChild("Splash")

	local DefaultServerSoundEvent = game:GetService("ReplicatedStorage"):FindFirstChild("DefaultServerSoundEvent")
	if DefaultServerSoundEvent then
		DefaultServerSoundEvent.OnClientEvent:connect(function(sound, playing, resetPosition)
			if UserSettings():IsUserFeatureEnabled("UserPlayCharacterLoopSoundWhenFE") then
				if resetPosition and sound.TimePosition ~= 0 then
					sound.TimePosition = 0
				end
				if sound.IsPlaying ~= playing then
					sound.Playing = playing
				end
			else
				if sound.TimePosition ~= 0 then
					sound.TimePosition = 0
				end
				if not sound.IsPlaying then
					sound.Playing = true
				end
			end
		end)
	end
end

local IsSoundFilteringEnabled = function()
	return game.Workspace.FilteringEnabled and SoundService.RespectFilteringEnabled
end

local Util
Util = {

	--Define linear relationship between (pt1x,pt2x) and (pt2x,pt2y). Evaluate this at x.
	YForLineGivenXAndTwoPts = function(x,pt1x,pt1y,pt2x,pt2y)
		--(y - y1)/(x - x1) = m
		local m = (pt1y - pt2y) / (pt1x - pt2x)
		--float b = pt1.y - m * pt1.x;
		local b = (pt1y - m * pt1x)
		return m * x + b
	end;

	--Clamps the value of "val" between the "min" and "max"
	Clamp = function(val,min,max)
		return math.min(max,math.max(min,val))
	end;

	--Gets the horizontal (x,z) velocity magnitude of the given part
	HorizontalSpeed = function(Head)
		local hVel = Head.Velocity + Vector3.new(0,-Head.Velocity.Y,0)
		return hVel.magnitude
	end;

	--Gets the vertical (y) velocity magnitude of the given part
	VerticalSpeed = function(Head)
		return math.abs(Head.Velocity.Y)
	end;

	--Setting Playing/TimePosition values directly result in less network traffic than Play/Pause/Resume/Stop
	--If these properties are enabled, use them.
	Play = function(sound)
		if IsSoundFilteringEnabled() then
			sound.CharacterSoundEvent:FireServer(true, true)
		end
		if sound.TimePosition ~= 0 then
			sound.TimePosition = 0
		end
		if not sound.IsPlaying then
			sound.Playing = true
		end
	end;

	Pause = function(sound)
		if UserSettings():IsUserFeatureEnabled("UserPlayCharacterLoopSoundWhenFE") and IsSoundFilteringEnabled() then
			sound.CharacterSoundEvent:FireServer(false, false)
		end
		if sound.IsPlaying then
			sound.Playing = false
		end
	end;

	Resume = function(sound)
		if UserSettings():IsUserFeatureEnabled("UserPlayCharacterLoopSoundWhenFE") and IsSoundFilteringEnabled() then
			sound.CharacterSoundEvent:FireServer(true, false)
		end
		if not sound.IsPlaying then
			sound.Playing = true
		end
	end;

	Stop = function(sound)
		if UserSettings():IsUserFeatureEnabled("UserPlayCharacterLoopSoundWhenFE") and IsSoundFilteringEnabled() then
			sound.CharacterSoundEvent:FireServer(false, true)
		end
		if sound.IsPlaying then
			sound.Playing = false
		end
		if sound.TimePosition ~= 0 then
			sound.TimePosition = 0
		end
	end;
}

do
	-- List of all active Looped sounds
	local playingLoopedSounds = {}

	-- Last seen Enum.HumanoidStateType
	local activeState = nil

	-- Verify and set that "sound" is in "playingLoopedSounds".
	function setSoundInPlayingLoopedSounds(sound)
		for i=1, #playingLoopedSounds do
			if playingLoopedSounds[i] == sound then
				return
			end
		end
		table.insert(playingLoopedSounds,sound)
	end

	-- Stop all active looped sounds except parameter "except". If "except" is not passed, all looped sounds will be stopped.
	function stopPlayingLoopedSoundsExcept(except)
		for i=#playingLoopedSounds,1,-1 do
			if playingLoopedSounds[i] ~= except then
				Util.Pause(playingLoopedSounds[i])
				table.remove(playingLoopedSounds,i)
			end
		end
	end

	-- Table of Enum.HumanoidStateType to handling function
	local stateUpdateHandler = {
		[Enum.HumanoidStateType.Dead] = function()
			stopPlayingLoopedSoundsExcept()
			local sound = Sounds[SFX.Died]
			Util.Play(sound)
		end;

		[Enum.HumanoidStateType.RunningNoPhysics] = function()
			stateUpdated(Enum.HumanoidStateType.Running)
		end;

		[Enum.HumanoidStateType.Running] = function()
			local sound = Sounds[SFX.Running]
			stopPlayingLoopedSoundsExcept(sound)

			if Util.HorizontalSpeed(Head) > 0.5 then
				Util.Resume(sound)
				setSoundInPlayingLoopedSounds(sound)
			else
				stopPlayingLoopedSoundsExcept()
			end
		end;

		[Enum.HumanoidStateType.Swimming] = function()
			if activeState ~= Enum.HumanoidStateType.Swimming and Util.VerticalSpeed(Head) > 0.1 then
				local splashSound = Sounds[SFX.Splash]
				splashSound.Volume = Util.Clamp(
					Util.YForLineGivenXAndTwoPts(
						Util.VerticalSpeed(Head),
						100, 0.28,
						350, 1),
					0,1)
				Util.Play(splashSound)
			end

			do
				local sound = Sounds[SFX.Swimming]
				stopPlayingLoopedSoundsExcept(sound)
				Util.Resume(sound)
				setSoundInPlayingLoopedSounds(sound)
			end
		end;

		[Enum.HumanoidStateType.Climbing] = function()
			local sound = Sounds[SFX.Climbing]
			if Util.VerticalSpeed(Head) > 0.1 then
				Util.Resume(sound)
				stopPlayingLoopedSoundsExcept(sound)
			else
				stopPlayingLoopedSoundsExcept()
			end
			setSoundInPlayingLoopedSounds(sound)
		end;

		[Enum.HumanoidStateType.Jumping] = function()
			if activeState == Enum.HumanoidStateType.Jumping then
				return
			end
			stopPlayingLoopedSoundsExcept()
			local sound = Sounds[SFX.Jumping]
			Util.Play(sound)
		end;

		[Enum.HumanoidStateType.GettingUp] = function()
			stopPlayingLoopedSoundsExcept()
			local sound = Sounds[SFX.GettingUp]
			Util.Play(sound)
		end;

		[Enum.HumanoidStateType.Freefall] = function()
			if activeState == Enum.HumanoidStateType.Freefall then
				return
			end
			local sound = Sounds[SFX.FreeFalling]
			sound.Volume = 0
			stopPlayingLoopedSoundsExcept()
		end;

		[Enum.HumanoidStateType.FallingDown] = function()
			stopPlayingLoopedSoundsExcept()
		end;

		[Enum.HumanoidStateType.Landed] = function()
			stopPlayingLoopedSoundsExcept()
			if Util.VerticalSpeed(Head) > 75 then
				local landingSound = Sounds[SFX.Landing]
				landingSound.Volume = Util.Clamp(
					Util.YForLineGivenXAndTwoPts(
						Util.VerticalSpeed(Head),
						50, 0,
						100, 1),
					0,1)
				Util.Play(landingSound)
			end
		end;

		[Enum.HumanoidStateType.Seated] = function()
			stopPlayingLoopedSoundsExcept()
		end;
	}

	-- Handle state event fired or OnChange fired
	function stateUpdated(state)
		if stateUpdateHandler[state] ~= nil then
			stateUpdateHandler[state]()
		end
		activeState = state
	end

	Humanoid.Died:connect(			function() stateUpdated(Enum.HumanoidStateType.Dead) 			end)
	Humanoid.Running:connect(		function() stateUpdated(Enum.HumanoidStateType.Running) 		end)
	Humanoid.Swimming:connect(		function() stateUpdated(Enum.HumanoidStateType.Swimming) 		end)
	Humanoid.Climbing:connect(		function() stateUpdated(Enum.HumanoidStateType.Climbing) 		end)
	Humanoid.Jumping:connect(		function() stateUpdated(Enum.HumanoidStateType.Jumping) 		end)
	Humanoid.GettingUp:connect(		function() stateUpdated(Enum.HumanoidStateType.GettingUp) 		end)
	Humanoid.FreeFalling:connect(		function() stateUpdated(Enum.HumanoidStateType.Freefall) 		end)
	Humanoid.FallingDown:connect(		function() stateUpdated(Enum.HumanoidStateType.FallingDown) 	end)

	-- required for proper handling of Landed event

	Humanoid.StateChanged:connect(function(old, new)
		stateUpdated(new)
	end)

	function onUpdate(stepDeltaSeconds, tickSpeedSeconds)
		local stepScale = stepDeltaSeconds / tickSpeedSeconds
		do
			local sound = Sounds[SFX.FreeFalling]
			if activeState == Enum.HumanoidStateType.Freefall then
				if Head.Velocity.Y < 0 and Util.VerticalSpeed(Head) > 75 then
					Util.Resume(sound)

					--Volume takes 1.1 seconds to go from volume 0 to 1
					local ANIMATION_LENGTH_SECONDS = 1.1

					local normalizedIncrement = tickSpeedSeconds / ANIMATION_LENGTH_SECONDS
					sound.Volume = Util.Clamp(sound.Volume + normalizedIncrement * stepScale, 0, 1)
				else
					sound.Volume = 0
				end
			else
				Util.Pause(sound)
			end
		end

		do
			local sound = Sounds[SFX.Running]
			if activeState == Enum.HumanoidStateType.Running then
				if Util.HorizontalSpeed(Head) < 0.5 then
					Util.Pause(sound)
				end
			end
		end
	end

	local lastTick = tick()
	local TICK_SPEED_SECONDS = 0.25
	while true do
		onUpdate(tick() - lastTick,TICK_SPEED_SECONDS)
		lastTick = tick()
		wait(TICK_SPEED_SECONDS)
	end

end


Prompt:
-- ROBLOX scripter hackers, see what you can do with this:
-- game:GetService("BadgeService"):UserHasBadge(userid, badgeid)

Response:
function OnTouch(part)
	if (part.Parent:FindFirstChild("Humanoid") ~= nil) then
		local p = game.Players:GetPlayerFromCharacter(part.Parent)
		if (p ~= nil) then
			print("Awarding BadgeID: " ..script.Parent.BadgeID.Value .. " to UserID: " .. p.userId)
			local b = game:GetService("BadgeService")
			b:AwardBadge(p.userId, script.Parent.BadgeID.Value)
		end
	end
end

script.Parent.Touched:connect(OnTouch)


Prompt: --Sizes

Response:
local xsize = script.Parent.Size.X
local ysize = script.Parent.Size.Y
local zsize = script.Parent.Size.Z


Prompt: -- If in-game, enable ctrl hotkeys for cloning and deleting

Response:
if Mode == 'Tool' then
	AssignHotkey({ 'LeftControl', 'C' }, CloneSelection);
	AssignHotkey({ 'RightControl', 'C' }, CloneSelection);
	AssignHotkey({ 'LeftControl', 'X' }, DeleteSelection);
	AssignHotkey({ 'RightControl', 'X' }, DeleteSelection);
end;


Prompt: --| Remote |--

Response: local Remote = Replicated.Access.Remotes


Prompt: -- Main loop for the entire game

Response:
while true do
	displayManager.updateStatus("Waiting for Players")

	displayManager.updateTime(0)

	repeat
		wait(1)
	until Players.NumPlayers >= gameSettings.minimumPlayers

	-- Actual Intermission
	displayManager.updateStatus("Intermission")
	gameTimer:start(gameSettings.intermissionDuration)
	displayManager.trackTimer(gameTimer)
	gameTimer.finished:Wait()

	roundManager.prepareGame()
	displayManager.updateStatus("Round in Progress")

	-- Waits until the roundEnd event has fired before continuing the script
	local endState = roundEnd.Event:Wait()

	-- Displays how the game ended to the player's GUI. Ex: Winner found, time up ...
	local resultString = roundManager.endRound()
	displayRoundResult:FireAllClients(resultString)

	-- Starts the end intermission. Will remove player weapons if still actively in game.
	displayManager.updateTime(0)
	wait(gameSettings.transitionEnd)
	roundManager.endGameIntermission()

	-- Resets the game by moving players back into the lobby and clearing used variables
	roundManager.resetGame()

end


Prompt:
--[=[
	@prop Util Folder
	@within KnitClient
	@readonly
	References the Util folder. Should only be accessed when using Knit as
	a standalone module. If using Knit from Wally, modules should just be
	pulled in via Wally instead of relying on Knit's Util folder, as this
	folder only contains what is necessary for Knit to run in Wally mode.
]=]

Response:
KnitClient.Util = script.Parent.Parent

local Promise = require(KnitClient.Util.Promise)
local Comm = require(KnitClient.Util.Comm)
local ClientComm = Comm.ClientComm

local controllers: {[string]: Controller} = {}
local services: {[string]: Service} = {}
local servicesFolder = nil

local started = false
local startedComplete = false
local onStartedComplete = Instance.new("BindableEvent")

local function DoesControllerExist(controllerName: string): boolean
	local controller: Controller? = controllers[controllerName]
	return controller ~= nil
end

local function GetServicesFolder()
	if not servicesFolder then
		servicesFolder = script.Parent:WaitForChild("Services")
	end
	return servicesFolder
end

local function GetMiddlewareForService(serviceName: string)
	local knitMiddleware = selectedOptions.Middleware or {}
	local serviceMiddleware = selectedOptions.PerServiceMiddleware[serviceName]
	return serviceMiddleware or knitMiddleware
end

local function BuildService(serviceName: string)
	local folder = GetServicesFolder()
	local middleware = GetMiddlewareForService(serviceName)
	local clientComm = ClientComm.new(folder, selectedOptions.ServicePromises, serviceName)
	local service = clientComm:BuildObject(middleware.Inbound, middleware.Outbound)
	services[serviceName] = service
	return service
end


Prompt: -- Provide functionality to the server API endpoint instance

Response:
ServerEndpoint.OnServerInvoke = function (Client, ...)
	return SyncModule.PerformAction(Client, ...);
end;


Prompt:
--[=[
	@param trigger KeyCode
	@param deadzoneThreshold number?
	@return number
	Gets the position of the given trigger. The triggers are usually going
	to be `Enum.KeyCode.ButtonL2` and `Enum.KeyCode.ButtonR2`. These trigger
	buttons are analog, and will output a value between the range of [0, 1].

	If `deadzoneThreshold` is not included, the `DefaultDeadzone` value is
	used instead.

	```lua
	local triggerAmount = gamepad:GetTrigger(Enum.KeyCode.ButtonR2)
	print(triggerAmount)
	```
]=]

Response:
function Gamepad:GetTrigger(trigger: Enum.KeyCode, deadzoneThreshold: number?): number
	return ApplyDeadzone(self.State[trigger].Position.Z, deadzoneThreshold or self.DefaultDeadzone)
end


Prompt:
----------------------------------
------------FUNCTIONS-------------
----------------------------------

Response:
function Receive(action, ...)
	local args = {...}
	if not ScriptReady then return end
	if action == "activate" then
		if not PlayingEnabled then
			Activate(args[1], args[2])
		end
	elseif action == "deactivate" then
		if PlayingEnabled then
			Deactivate()
		end
	elseif action == "play" then
		if Player ~= args[1] then
			PlayNoteServer(args[2], args[3], args[4], args[5])
		end
	end
end
function Activate(cameraCFrame, sounds)
	PlayingEnabled = true
	MakeHumanoidConnections()
	MakeKeyboardConnections()
	MakeGuiConnections()
	SetCamera(cameraCFrame)
	SetSounds(sounds)
	ShowPiano()
end
function Deactivate()
	PlayingEnabled = false
	BreakHumanoidConnections()
	BreakKeyboardConnections()
	BreakGuiConnections()
	HidePiano()
	HideSheets()
	ReturnCamera()
	Jump()
end
function PlayNoteClient(note)
	PlayNoteSound(note)
	HighlightPianoKey(note)
	Connector:FireServer("play", note)
end
function PlayNoteServer(note, point, range)
	PlayNoteSound(note, point, range)
end
function Abort()
	Connector:FireServer("abort")
end


Prompt: --returns the wielding player of this tool

Response:
function getPlayer()
	local char = Tool.Parent
	return game:GetService("Players"):GetPlayerFromCharacter(Character)
end

function Toss(direction)
	local handlePos = Vector3.new(Tool.Handle.Position.X, 0, Tool.Handle.Position.Z)
	local spawnPos = Character.Head.Position

	spawnPos  = spawnPos + (direction * 5)

	local Object = Tool.Handle:Clone()
	Object.Burn.Attachment.Debris.Enabled = true
	Object.ThinkFast:Destroy()
	Object.Parent = workspace
	Object.Swing.Pitch = Random.new():NextInteger(90, 110)/100
	Object.Swing:Play()
	Object.CanCollide = true
	Object.CFrame = Tool.Handle.CFrame
	Object.Velocity = (direction*AttackVelocity) + Vector3.new(0,AttackVelocity/7.5,0)
	Object.Trail.Enabled = true

	local rand = 11.25
	Object.RotVelocity = Vector3.new(Random.new():NextNumber(-rand,rand),Random.new():NextNumber(-rand,rand),Random.new():NextNumber(-rand,rand))
	Object:SetNetworkOwner(getPlayer())

	local ScriptClone = DamageScript:Clone()
	ScriptClone.Parent = Object
	ScriptClone.Disabled = false

	local tag = Instance.new("ObjectValue")
	tag.Value = getPlayer()
	tag.Name = "creator"
	tag.Parent = Object
end

PowerRemote.OnServerEvent:Connect(function(player, Power)
	local holder = getPlayer()
	if holder ~= player then return end

	AttackVelocity = Power
end)

TossRemote.OnServerEvent:Connect(function(player, mousePosition)
	local holder = getPlayer()
	if holder ~= player then return end

	if Cooldown.Value == true then return end
	Cooldown.Value = true

	if Humanoid and Humanoid.RigType == Enum.HumanoidRigType.R15 then
		TossRemote:FireClient(getPlayer(), "PlayAnimation", "Animation")
	end
	local targetPos = mousePosition.p
	local lookAt = (targetPos - Character.Head.Position).unit

	local SecretRNG = Random.new():NextInteger(1,10) --Change RNG value here
	if SecretRNG == 1 then
		local ChucklenutsSound = Tool.Handle.ThinkFast:Play()
	end

	Toss(lookAt)
	task.wait(CooldownTime)
	Cooldown.Value = false
end)

Tool.Equipped:Connect(function()
	Character = Tool.Parent
	Humanoid = Character:FindFirstChildOfClass("Humanoid")
end)

Tool.Unequipped:Connect(function()
	Character = nil
	Humanoid = nil
end)


Prompt: -- But in this script, the animation is loaded only ONCE.

Response:
Mouse.KeyDown:connect(function(key)
     key = string.lower(key)
   if string.byte(key) == 48 then
        s:Play()
        humanoid.WalkSpeed = 67
    end
end)

Mouse.KeyUp:connect(function(key)
    key = string.lower(key)
if string.byte(key) == 48 then
        s:Stop()
        humanoid.WalkSpeed = 7
    end
end)


Response:
function getHumanoid(model)
	for _, v in pairs(model:GetChildren()) do
		if v:IsA'Humanoid' then
			return v
		end
	end
end

local ai = script.Parent
local human = getHumanoid(ai)
local hroot = ai.HumanoidRootPart
local zspeed = hroot.Velocity.magnitude

local pfs = game:GetService("PathfindingService")

function GetPlayerNames()
	local players = game:GetService('Players'):GetChildren()
	local name = nil
	for _, v in pairs(players) do
		if v:IsA'Player' then
			name = tostring(v.Name)
		end
	end
	return name
end

function GetPlayersBodyParts(t)
	local torso = t
	if torso then
		local figure = torso.Parent
		for _, v in pairs(figure:GetChildren()) do
			if v:IsA'Part' then
				return v.Name
			end
		end
	else
		return "HumanoidRootPart"
	end
end

function GetTorso(part)
	local chars = game.Workspace:GetChildren()
	local torso = nil
	for _, v in pairs(chars) do
		if v:IsA'Model' and v ~= script.Parent and v.Name == GetPlayerNames() and not v:FindFirstChild("Enemy") then
			local charRoot = v:FindFirstChild'HumanoidRootPart'
			if (charRoot.Position - part).magnitude < SearchDistance then
				torso = charRoot
			end
		end
	end
	return torso
end

for _, zambieparts in pairs(ai:GetChildren()) do
	if zambieparts:IsA'Part' then
		zambieparts.Touched:connect(function(p)
			if p.Parent.Name == GetPlayerNames() and p.Parent.Name ~= ai.Name then -- damage
				local enemy = p.Parent
				local enemyhuman = getHumanoid(enemy)
				enemyhuman:TakeDamage(aiDamage)
			end
		end)
	end
end


Prompt: --while wait() do

Response:
if char then
game.StarterGui:SetCoreGuiEnabled(2,EnableBackpackGui)
for i,v in ipairs(char:GetChildren()) do
if v.className ~= ""..Weapon.."" then
wait()
if db == 1 then
player.Character.Humanoid:EquipTool(tool)
db=2
end
end
end
script.Parent.Unequipped:connect(function()
db=1
end)
end


Prompt: --Update list of players in admin panel

Response:
local selectPlrFrame = panel.Pages.MainButtonsFrame.ButtonsScroller.SelectPlayerFrame
local scroller = selectPlrFrame.PlayersScroller
local selectedFrame = selectPlrFrame.SelectedPlayerFrame
selectedFrame.Visible = false

function updatePlayers()
	for i, child in pairs(scroller:GetChildren()) do
		if child:IsA("TextButton") then
			child:Destroy()
		end
	end

	for i, plr in pairs(game.Players:GetPlayers()) do

		local btn = script.PlayerButton:Clone()

		local name = plr.Name
		btn.PlayerName.Text = name

		local image = game.Players:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
		btn.PlayerImage.Image = image

		btn.MouseButton1Click:Connect(function()

			selectedFrame.PlayerName.Text = name
			selectedFrame.DisplayName.Text = "@" .. plr.DisplayName
			selectedFrame.UserId.Text = plr.UserId
			selectedFrame.InGame.Text = "Currently in server 🟢"
			selectedFrame.PlayerImage.Image = image

			selectedFrame.Visible = true
		end)

		btn.Parent = scroller
	end
end
updatePlayers()
game.Players.PlayerAdded:Connect(updatePlayers)
game.Players.PlayerRemoving:Connect(updatePlayers)


Prompt:
--[=[
	@tag Component Class
	@return {Component}
	Gets a table array of all existing component objects. For example,
	if there was a component class linked to the "MyComponent" tag,
	and three Roblox instances in your game had that same tag, then
	calling `GetAll` would return the three component instances.

	```lua
	local MyComponent = Component.new({Tag = "MyComponent"})

	-- ...

	local components = MyComponent:GetAll()
	for _,component in ipairs(components) do
		component:DoSomethingHere()
	end
	```
]=]

Response:
function Component:GetAll()
	return self[KEY_COMPONENTS]
end


Prompt:
--////////////////////////////////////////////////////////////////////////////////////////////
--////////////////////////////////////////////////////////////// Code to do chat window fading
--////////////////////////////////////////////////////////////////////////////////////////////

Response:
function CheckIfPointIsInSquare(checkPos, topLeft, bottomRight)
	return (topLeft.X <= checkPos.X and checkPos.X <= bottomRight.X and
		topLeft.Y <= checkPos.Y and checkPos.Y <= bottomRight.Y)
end

local backgroundIsFaded = false
local textIsFaded = false
local lastTextFadeTime = 0
local lastBackgroundFadeTime = 0

local fadedChanged = Instance.new("BindableEvent")
local mouseStateChanged = Instance.new("BindableEvent")
local chatBarFocusChanged = Instance.new("BindableEvent")

function DoBackgroundFadeIn(setFadingTime)
	lastBackgroundFadeTime = tick()
	backgroundIsFaded = false
	fadedChanged:Fire()
	ChatWindow:FadeInBackground((setFadingTime or ChatSettings.ChatDefaultFadeDuration))

	local currentChannelObject = ChatWindow:GetCurrentChannel()
	if (currentChannelObject) then

		local Scroller = MessageLogDisplay.Scroller
		Scroller.ScrollingEnabled = true
		Scroller.ScrollBarThickness = moduleMessageLogDisplay.ScrollBarThickness
	end
end

function DoBackgroundFadeOut(setFadingTime)
	lastBackgroundFadeTime = tick()
	backgroundIsFaded = true
	fadedChanged:Fire()
	ChatWindow:FadeOutBackground((setFadingTime or ChatSettings.ChatDefaultFadeDuration))

	local currentChannelObject = ChatWindow:GetCurrentChannel()
	if (currentChannelObject) then

		local Scroller = MessageLogDisplay.Scroller
		Scroller.ScrollingEnabled = false
		Scroller.ScrollBarThickness = 0
	end
end

function DoTextFadeIn(setFadingTime)
	lastTextFadeTime = tick()
	textIsFaded = false
	fadedChanged:Fire()
	ChatWindow:FadeInText((setFadingTime or ChatSettings.ChatDefaultFadeDuration) * 0)
end

function DoTextFadeOut(setFadingTime)
	lastTextFadeTime = tick()
	textIsFaded = true
	fadedChanged:Fire()
	ChatWindow:FadeOutText((setFadingTime or ChatSettings.ChatDefaultFadeDuration))
end

function DoFadeInFromNewInformation()
	DoTextFadeIn()
	if ChatSettings.ChatShouldFadeInFromNewInformation then
		DoBackgroundFadeIn()
	end
end

function InstantFadeIn()
	DoBackgroundFadeIn(0)
	DoTextFadeIn(0)
end

function InstantFadeOut()
	DoBackgroundFadeOut(0)
	DoTextFadeOut(0)
end

local mouseIsInWindow = nil
function UpdateFadingForMouseState(mouseState)
	mouseIsInWindow = mouseState

	mouseStateChanged:Fire()

	if (ChatBar:IsFocused()) then return end

	if (mouseState) then
		DoBackgroundFadeIn()
		DoTextFadeIn()
	else
		DoBackgroundFadeIn()
	end
end

spawn(function()
	while true do
		RunService.RenderStepped:wait()

		while (mouseIsInWindow or ChatBar:IsFocused()) do
			if (mouseIsInWindow) then
				mouseStateChanged.Event:wait()
			end
			if (ChatBar:IsFocused()) then
				chatBarFocusChanged.Event:wait()
			end
		end

		if (not backgroundIsFaded) then
			local timeDiff = tick() - lastBackgroundFadeTime
			if (timeDiff > ChatSettings.ChatWindowBackgroundFadeOutTime) then
				DoBackgroundFadeOut()
			end

		elseif (not textIsFaded) then
			local timeDiff = tick() - lastTextFadeTime
			if (timeDiff > ChatSettings.ChatWindowTextFadeOutTime) then
				DoTextFadeOut()
			end

		else
			fadedChanged.Event:wait()

		end

	end
end)

function getClassicChatEnabled()
	if ChatSettings.ClassicChatEnabled ~= nil then
		return ChatSettings.ClassicChatEnabled
	end
	return Players.ClassicChat
end

function getBubbleChatEnabled()
	if ChatSettings.BubbleChatEnabled ~= nil then
		return ChatSettings.BubbleChatEnabled
	end
	return Players.BubbleChat
end

function bubbleChatOnly()
 	return not getClassicChatEnabled() and getBubbleChatEnabled()
end

function UpdateMousePosition(mousePos, ignoreForFadeIn)
	if not (moduleApiTable.Visible and moduleApiTable.IsCoreGuiEnabled and (moduleApiTable.TopbarEnabled or ChatSettings.ChatOnWithTopBarOff)) then return end

	if bubbleChatOnly() then
		return
	end

	local windowPos = ChatWindow.GuiObject.AbsolutePosition
	local windowSize = ChatWindow.GuiObject.AbsoluteSize

	local newMouseState = CheckIfPointIsInSquare(mousePos, windowPos, windowPos + windowSize)

	if FFlagFixChatWindowHoverOver then
		if ignoreForFadeIn and newMouseState == true then
			return
		end
	end

	if (newMouseState ~= mouseIsInWindow) then
		UpdateFadingForMouseState(newMouseState)
	end
end

UserInputService.InputChanged:connect(function(inputObject, gameProcessedEvent)
	if (inputObject.UserInputType == Enum.UserInputType.MouseMovement) then
		local mousePos = Vector2.new(inputObject.Position.X, inputObject.Position.Y)
		UpdateMousePosition(mousePos, --[[ ignoreForFadeIn = ]] gameProcessedEvent)
	end
end)

UserInputService.TouchTap:connect(function(tapPos, gameProcessedEvent)
	UpdateMousePosition(tapPos[1], --[[ ignoreForFadeIn = ]] false)
end)

UserInputService.TouchMoved:connect(function(inputObject, gameProcessedEvent)
	local tapPos = Vector2.new(inputObject.Position.X, inputObject.Position.Y)
	UpdateMousePosition(tapPos, --[[ ignoreForFadeIn = ]] false)
end)

if not FFlagFixMouseCapture then
	UserInputService.Changed:connect(function(prop)
		if prop == "MouseBehavior" then
			if UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter then
				local windowPos = ChatWindow.GuiObject.AbsolutePosition
				local windowSize = ChatWindow.GuiObject.AbsoluteSize
				local screenSize = GuiParent.AbsoluteSize

				local centerScreenIsInWindow = CheckIfPointIsInSquare(screenSize/2, windowPos, windowPos + windowSize)
				if centerScreenIsInWindow then
					UserInputService.MouseBehavior = Enum.MouseBehavior.Default
				end
			end
		end
	end)
end


Prompt: --Blood Parts Function

Response:
local createBlood = function(position)

	local randomSize = math.random(2, 20) / 10

	local bloodClone = bloodPart:Clone()
	bloodClone.Position = position + Vector3.new(0, 0.05, 0)
	bloodClone.Size = Vector3.new(randomSize, 0.1, randomSize)

	bloodClone.Parent = bloodCache

	if math.random(2) == 1 then
		bloodClone.BloodSound:Play()
	end

	return bloodClone
end


Prompt:
--[=[
	This can't be cheap. Consider deeply if you want this or not.

	@param selectFromBrio ((value: T) -> U)?
	@return (source: Observable<Brio<T>>) -> Observable<Brio{U}>
]=]

Response:
function RxBrioUtils.reduceToAliveList(selectFromBrio)
	assert(type(selectFromBrio) == "function" or selectFromBrio == nil, "Bad selectFromBrio")

	return function(source)
		return Observable.new(function(sub)
			local topMaid = Maid.new()

			local subscribed = true
			topMaid:GiveTask(function()
				subscribed = false
			end)
			local aliveBrios = {}
			local fired = false

			local function updateBrios()
				if not subscribed then -- No work if we don't need to.
					return
				end

				aliveBrios = BrioUtils.aliveOnly(aliveBrios)
				local values = {}
				if selectFromBrio then
					for _, brio in pairs(aliveBrios) do
						-- Hope for no side effects
						local value = selectFromBrio(brio:GetValue())
						assert(value ~= nil, "Bad value")

						table.insert(values, value)
					end
				else
					for _, brio in pairs(aliveBrios) do
						local value = brio:GetValue()
						assert(value ~= nil, "Bad value")

						table.insert(values, value)
					end
				end

				local newBrio = BrioUtils.first(aliveBrios, values)
				topMaid._lastBrio = newBrio

				fired = true
				sub:Fire(newBrio)
			end

			local function handleNewBrio(brio)
				-- Could happen due to throttle or delay...
				if brio:IsDead() then
					return
				end

				local maid = Maid.new()
				topMaid[maid] = maid -- Use maid as key so it's unique (reemitted brio)

				maid:GiveTask(function() -- GC properly
					topMaid[maid] = nil
					updateBrios()
				end)
				maid:GiveTask(brio:GetDiedSignal():Connect(function()
					topMaid[maid] = nil
				end))

				table.insert(aliveBrios, brio)
				updateBrios()
			end

			topMaid:GiveTask(source:Subscribe(
				function(brio)
					if not Brio.isBrio(brio) then
						warn(("[RxBrioUtils.mergeToAliveList] - Not a brio, %q"):format(tostring(brio)))
						topMaid._lastBrio = nil
						sub:Fail("Not a brio")
						return
					end

					handleNewBrio(brio)
				end,
				function(...)
					sub:Fail(...)
				end,
				function(...)
					sub:Complete(...)
				end))

			-- Make sure we emit an empty list if we discover nothing
			if not fired then
				updateBrios()
			end

			return topMaid
		end)
	end
end


Prompt:
-- ActiveCast class type.
-- The ActiveCast type represents a currently running cast.


Prompt: --[[Transmission]]

Response:
	Tune.TransModes		= {"Auto", "Semi"}								--[[
	[Modes]
		"Auto"		: Automatic shifting
		"Semi"		: Clutchless manual shifting, dual clutch transmission
		"Manual"	: Manual shifting with clutch

		>Include within brackets
			eg: {"Semi"} or {"Auto", "Manual"}
		>First mode is default mode													]]

	--Automatic Settings
	Tune.AutoShiftMode	= "Speed"												--[[
	[Modes]
		"Speed"		: Shifts based on wheel speed
		"RPM"		: Shifts based on RPM											]]
	Tune.AutoUpThresh	= -200		--Automatic upshift point 	(relative to peak RPM, positive = Over-rev)
	Tune.AutoDownThresh = 1400		--Automatic downshift point (relative to peak RPM, positive = Under-rev)

	--Gear Ratios
	Tune.FinalDrive		= 4.06			-- Gearing determines top speed and wheel torque
	Tune.Ratios			= {				-- Higher ratio = more torque, Lower ratio = higher top speed
		--[[Reverse]]	3.70		,	-- Copy and paste a ratio to add a gear
		--[[Neutral]]	0			,	-- Ratios can also be deleted
		--[[ 1 ]]		3.53		,	-- Reverse, Neutral, and 1st gear are required
		--[[ 2 ]]		2.04		,
		--[[ 3 ]]		1.38		,
		--[[ 4 ]]		1.03		,
		--[[ 5 ]]		0.81		,
		--[[ 6 ]]		0.64		,
	}
	Tune.FDMult			= 1.5			-- Ratio multiplier (Change this value instead of FinalDrive if car is struggling with torque ; Default = 1)


Prompt: -- Module.

Response:
local _Confetti = {}; _Confetti.__index = _Confetti;
	-- Set the gravitational pull for the confetti.
	local gravity = Vector2.new(0,1);
	function _Confetti.setGravity(paramVec2)
		gravity = paramVec2;
	end;
	-- Create a confetti particle.
	function _Confetti.createParticle(paramEmitter, paramForce, paramParent, paramColors)
		local _Particle = {}; setmetatable(_Particle, _Confetti);
		colors = paramColors;
		-- Adjust forces.
		local xforce = paramForce.X; if (xforce < 0) then xforce = xforce * -1; end;
		local distanceFromZero = 0 - xforce;
		paramForce = Vector2.new(paramForce.X, paramForce.Y + (distanceFromZero * 0.75));
		if (paramColors == nil) then paramColors = colors; end;
		-- Confetti data.
		_Particle.EmitterPosition = paramEmitter;
		_Particle.EmitterPower = paramForce;
		_Particle.Position = Vector2.new(0,0);
		_Particle.Power = paramForce;
		_Particle.Color = paramColors[math.random(#paramColors)];
		local function getParticle()
			local label = shapes[math.random(#shapes)]:Clone();
			label.ImageColor3 = _Particle.Color;
			label.Parent = paramParent;
			label.Rotation = math.random(360);
			label.Visible = true;
			label.ZIndex = 20;
			return label;
		end;
		_Particle.Label = getParticle();
		_Particle.DefaultSize = 30;
		_Particle.Size = 1; _Particle.Side = -1;
		_Particle.OutOfBounds = false;
		_Particle.Enabled = false;
		_Particle.Cycles = 0;
		return _Particle;
	end;
	-- Update the position of the confetti.
	function _Confetti:Update(paramDeltaTime)
		if (self.Enabled and self.OutOfBounds) then
			self.Label.ImageColor3 = self.Color;
			self.Position = Vector2.new(0,0);
			self.Power = Vector2.new(self.EmitterPower.X + math.random(10)-5, self.EmitterPower.Y + math.random(10)-5);
			self.Cycles = self.Cycles + 1;
		end;
		if (
			(not(self.Enabled) and self.OutOfBounds) or
			(not(self.Enabled) and (self.Cycles == 0))) then
				self.Label.Visible = false;
				self.OutOfBounds = true;
				self.Color = colors[math.random(#colors)];
				return;
		else
			self.Label.Visible = true;
		end;
		local startPosition, currentPosition, currentPower = self.EmitterPosition, self.Position, self.Power;
		local imageLabel = self.Label;
		-- Apply change.
		if (imageLabel) then
			-- Update position.
			local newPosition = Vector2.new(currentPosition.X - currentPower.X, currentPosition.Y - currentPower.Y);
			local newPower = Vector2.new((currentPower.X/1.09) - gravity.X, (currentPower.Y/1.1) - gravity.Y);
			local ViewportSize = Camera.ViewportSize;
			imageLabel.Position = UDim2.new(startPosition.X, newPosition.X, startPosition.Y, newPosition.Y);
			self.OutOfBounds =
				(imageLabel.AbsolutePosition.X > ViewportSize.X and gravity.X > 0) or
				(imageLabel.AbsolutePosition.Y > ViewportSize.Y and gravity.Y > 0) or
				(imageLabel.AbsolutePosition.X < 0  and gravity.X < 0) or
				(imageLabel.AbsolutePosition.Y < 0 and gravity.Y < 0);
			self.Position, self.Power = newPosition, newPower;
			-- Start spinning if it's reached max height.
			if (newPower.Y < 0) then
				if (self.Size <= 0) then
					self.Side = 1;
					imageLabel.ImageColor3 = self.Color;
				end;
				if (self.Size >= self.DefaultSize) then
					self.Side = -1;
					imageLabel.ImageColor3 = Color3.new(self.Color.r * 0.65, self.Color.g * 0.65, self.Color.b * 0.65);
				end;
				self.Size = self.Size + (self.Side * 2);
				imageLabel.Size = UDim2.new(0, self.DefaultSize, 0, self.Size);
			end;
		end;
	end;
	-- Stops a confetti from firing again once it's out of bounds.
	function _Confetti:Toggle()
		self.Enabled = not(self.Enabled);
	end;

	function _Confetti:SetColors(paramColors)
		colors = paramColors;
	end;

return _Confetti;


Prompt: --		bg.CFrame = bg.CFrame * CFrame.Angles(0,0,0)

Response:
		IfOnLand()
		bv.Velocity = Vector3.new(0,0,0)
		seat.Anchored = true
		seat.Velocity = Vector3.new(0,0,0)
		wait()
		seat.Anchored = false
	end

end)

seat.Changed:connect(function(property)
if property == "Occupant" then
if seat.Occupant then
local p = game.Players:GetPlayerFromCharacter(seat.Occupant.Parent)
if p then
DriveEnabled = true
StartEngine()
end
else
walk:Stop()
DriveEnabled = false
lastLodged = tick()
wait(0.3)
Speed = 0
bv.Velocity = Vector3.new(0,0,0)
IfOnLand()
end
end
end)

local DespawnCoroutine = coroutine.wrap(function()
while wait(1) do
if tick()-breakTime >= 0 then
sp:Destroy()
end
end
end)
DespawnCoroutine()


Prompt: -- Theme UI to current tool

Response:
ToolChanged:Connect(function (Tool)
	coroutine.wrap(RecolorHandle)(Tool.Color);
	coroutine.wrap(Selection.RecolorOutlines)(Tool.Color);
end);