function Explode()if Crashed.Value==false then Crashed.Value=true Plane:BreakJoints()local y=Instance.new("\069\120\112\108\111\115\105\111\110")y.Parent=game.Workspace y.Position=Engine.Position y.BlastRadius=(Plane:GetModelSize()).magnitude y.BlastPressure=200000 if Engine:findFirstChild("\084\104\114\117\115\116")then Engine.Thrust:remove()end if Engine:findFirstChild("\068\105\114\101\099\116\105\111\110")then Engine.Direction:remove()end coroutine.resume(coroutine.create(function()wait(5)Plane:Destroy()end))end end function GetPlaneParts(y)for y,J in pairs(y:GetChildren())do if J:IsA("\066\097\115\101\080\097\114\116")then table.insert(Parts,J)end GetPlaneParts(J)end end function onAutoCrash()if AutoCrash.Value==true then Plane:BreakJoints()Explode()Engine.Thrust:remove()Engine.Direction:remove()end end function DetectExplosions(y)if y.ClassName=="\069\120\112\108\111\115\105\111\110"then if y.BlastPressure>0 then y.Hit:connect(function(y,J)if y==Engine then if Crashed.Value==false then Explode()end end end)end end end GetPlaneParts(Plane)for y,J in pairs(Parts)do J.Touched:connect(function(y)if not Ejected.Value then if CanCrash.Value==true then if Crashed.Value==false then if not y:IsDescendantOf(Plane)then if y.CanCollide==true and y.Transparency~=1 then if y:findFirstChild("\080\108\097\110\101\084\097\103")and y.PlaneTag.Value~=Plane or not y:findFirstChild("\080\108\097\110\101\084\097\103")then if Engine.Velocity.magnitude>=Force.Value then local y=game.Players:GetPlayerFromCharacter(Plane.Parent)local J=y.Backpack:findFirstChild("\080\108\097\110\101")if J then J.Deselect0.Value=true end wait(.01)Explode()end end end end end end elseif Ejected.Value then if Crashed.Value==false then if not y:IsDescendantOf(Plane)then if y.CanCollide and y.Transparency~=1 then local J=y:findFirstChild("\080\108\097\110\101\084\097\103")if J and J.Value~=Plane or not J then if y.Parent.Name~="\069\106\101\099\116\111\114\083\101\097\116"then if not(game:GetService("\080\108\097\121\101\114\115")):GetPlayerFromCharacter(y.Parent)then local y=game.Players:GetPlayerFromCharacter(Plane.Parent)local J=y.Backpack:findFirstChild("\080\108\097\110\101")if J then J.Deselect0.Value=true end wait(.01)Explode()end end end end end end end end)end game.Workspace.DescendantAdded:connect(DetectExplosions)AutoCrash.Changed:connect(onAutoCrash)
--------------------------------------------------------------------------
function Explode() --This function makes the plane explode
	if Crashed.Value == false then
		Crashed.Value = true
		Plane:BreakJoints()
		local Explosion = Instance.new("Explosion")
		Explosion.Parent = game.Workspace
		Explosion.Position = Engine.Position
		Explosion.BlastRadius = Plane:GetModelSize().magnitude --This makes the BlastRadius the size of the plane
		Explosion.BlastPressure = 200000
		if Engine:findFirstChild("Thrust") then
			Engine.Thrust:remove()
		end
		if Engine:findFirstChild("Direction") then
			Engine.Direction:remove()
		end
		coroutine.resume(coroutine.create(function()
			wait(5)
			Plane:Destroy()
		end))
	end
end

function GetPlaneParts(Model) --This function gets all the parts on the plane
	for _, v in pairs(Model:GetChildren()) do
		if v:IsA("BasePart") then
			table.insert(Parts, v) --This inserts all the parts into the "Parts" table
		end
		GetPlaneParts(v)
	end
end

function onAutoCrash() --This function is activated when the AutoCrash value becomes true
	if AutoCrash.Value == true then
		Plane:BreakJoints()
		Explode()
		Engine.Thrust:remove()
		Engine.Direction:remove()
	end
end

function DetectExplosions(Object) --This is a function that I created which detects explosions in the workspace
	if Object.ClassName == "Explosion" then --If the object detected was an explosion...
		if Object.BlastPressure > 0 then
			Object.Hit:connect(function(HitPart, Distance)
				if HitPart == Engine then
					if Crashed.Value == false then
						Explode()
					end
				end
			end)
		end
	end
end

GetPlaneParts(Plane) --This activates the "GetPlaneParts" function
for _, v in pairs(Parts) do --This gets all the parts in the "Parts" table
	v.Touched:connect(function(Object) --This is activated if any of the bricks are touched
		if not Ejected.Value then
			if CanCrash.Value == true then
				if Crashed.Value == false then
					if not Object:IsDescendantOf(Plane) then
						if Object.CanCollide == true and Object.Transparency ~= 1 then --This prevents your from crashing because your flares hit you
							if
								(Object:findFirstChild("PlaneTag") and Object.PlaneTag.Value ~= Plane)
								or (not Object:findFirstChild("PlaneTag"))
							then
								if Engine.Velocity.magnitude >= Force.Value then --If that part is going faster than the Force speed...
									local Player = game.Players:GetPlayerFromCharacter(Plane.Parent)
									local PlaneTool = Player.Backpack:findFirstChild("Plane")
									if PlaneTool then
										PlaneTool.Deselect0.Value = true
									end
									wait(0.01)
									Explode()
								end
							end
						end
					end
				end
			end
		elseif Ejected.Value then
			if Crashed.Value == false then
				if not Object:IsDescendantOf(Plane) then
					if Object.CanCollide and Object.Transparency ~= 1 then
						local PlaneTag = Object:findFirstChild("PlaneTag")
						if (PlaneTag and PlaneTag.Value ~= Plane) or not PlaneTag then
							if Object.Parent.Name ~= "EjectorSeat" then
								if not game:GetService("Players"):GetPlayerFromCharacter(Object.Parent) then
									local Player = game.Players:GetPlayerFromCharacter(Plane.Parent)
									local PlaneTool = Player.Backpack:findFirstChild("Plane")
									if PlaneTool then
										PlaneTool.Deselect0.Value = true
									end
									wait(0.01)
									Explode()
								end
							end
						end
					end
				end
			end
		end
	end)
end
game.Workspace.DescendantAdded:connect(DetectExplosions) --The detect explosions is a childadded function
AutoCrash.Changed:connect(onAutoCrash) --Pretty self explanatory. When the AutoCrash value is changed, the "onAutoCrash" function is activated
