function Explode()if Crashed.Value==false then Crashed.Value=true Plane:BreakJoints()local T=Instance.new("\069\120\112\108\111\115\105\111\110")T.Parent=game.Workspace T.Position=Engine.Position T.BlastRadius=(Plane:GetModelSize()).magnitude T.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(T)for T,G in pairs(T:GetChildren())do if G:IsA("\066\097\115\101\080\097\114\116")then table.insert(Parts,G)end GetPlaneParts(G)end end function onAutoCrash()if AutoCrash.Value==true then Plane:BreakJoints()Explode()Engine.Thrust:remove()Engine.Direction:remove()end end function DetectExplosions(T)if T.ClassName=="\069\120\112\108\111\115\105\111\110"then if T.BlastPressure>0 then T.Hit:connect(function(T,G)if T==Engine then if Crashed.Value==false then Explode()end end end)end end end GetPlaneParts(Plane)for T,G in pairs(Parts)do G.Touched:connect(function(T)if not Ejected.Value then if CanCrash.Value==true then if Crashed.Value==false then if not T:IsDescendantOf(Plane)then if T.CanCollide==true and T.Transparency~=1 then if T:findFirstChild("\080\108\097\110\101\084\097\103")and T.PlaneTag.Value~=Plane or not T:findFirstChild("\080\108\097\110\101\084\097\103")then if Engine.Velocity.magnitude>=Force.Value then local T=game.Players:GetPlayerFromCharacter(Plane.Parent)local G=T.Backpack:findFirstChild("\080\108\097\110\101")if G then G.Deselect0.Value=true end wait(.01)Explode()end end end end end end elseif Ejected.Value then if Crashed.Value==false then if not T:IsDescendantOf(Plane)then if T.CanCollide and T.Transparency~=1 then local G=T:findFirstChild("\080\108\097\110\101\084\097\103")if G and G.Value~=Plane or not G then if T.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(T.Parent)then local T=game.Players:GetPlayerFromCharacter(Plane.Parent)local G=T.Backpack:findFirstChild("\080\108\097\110\101")if G then G.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
