function CheckPlayer(n)if Customize.GroupSpecific.Value then if not n:IsInGroup(Customize.GroupSpecific.GroupID.Value)then return false end end return true end function CreateWarning(n)local u=assert(LoadLibrary("\082\098\120\071\117\105"))local t=Instance.new("\083\099\114\101\101\110\071\117\105")t.Name="\078\111\116\073\110\071\114\111\117\112\071\117\105"local C=u.CreateStyledMessageDialog("\089\111\117 \097\114\101 \110\111\116 \105\110 \116\104\105\115 \112\108\097\110\101\'\115 \103\114\111\117\112\033",n.Name.."\044 \121\111\117 \097\114\101 \110\111\116 \097 \112\097\114\116 \111\102 \116\104\101 \103\114\111\117\112 \116\104\097\116 \116\104\105\115 \112\108\097\110\101 \105\115 \105\110\033 \080\108\101\097\115\101 \101\120\105\116 \116\104\101 \112\108\097\110\101\033","\067\111\110\102\105\114\109",{{Text="\079\075",Function=function()if t.Parent then local n=t:findFirstChild("\077\101\115\115\097\103\101\068\105\097\108\111\103")if n then n:TweenPosition(UDim2.new(.25,0,0,-165),"\073\110","\066\097\099\107",.7,true)end wait(.7)t:Destroy()end end}})C.Parent=t t.Parent=n.PlayerGui return t end function GivePlaneTool(n)if n.Name=="\083\101\097\116\087\101\108\100"then Player=game.Players:GetPlayerFromCharacter(n.Part1.Parent)if Player then local n=CheckPlayer(Player)if n then PlaneMain.Parent=Player.Character Plane=PlaneTool:clone()Plane.Parent=Player.Backpack Plane.Main.Disabled=false else if Customize.GroupSpecific.KillOnEnter.Value then wait(.1)if Player.Character then Player.Character.Humanoid.Health=0 end else local n=CreateWarning(Player)delay(7,function()if n.Parent then local u=n:findFirstChild("\077\101\115\115\097\103\101\068\105\097\108\111\103")if u then u:TweenPosition(UDim2.new(.25,0,0,-165),"\073\110","\066\097\099\107",.7,true)end wait(.7)n:Destroy()end end)end end end end end function RemovePlaneTool(n)if n.Name=="\083\101\097\116\087\101\108\100"then if Player and Player.PlayerGui:findFirstChild("\078\111\116\073\110\071\114\111\117\112\071\117\105")then Player.PlayerGui.NotInGroupGui:Destroy()end if Plane then Plane.Deselect0.Value=Plane.ToolSelect.Value wait(.01)Plane:remove()if Player.Character.Humanoid.Health<=0 then PlaneMain:BreakJoints()Crashed.Value=true delay(5,function()PlaneMain:Destroy()end)elseif Player.Character.Humanoid.Health>0 then PlaneMain.Parent=Origin.Value end end end end Seat.ChildAdded:connect(GivePlaneTool)Seat.ChildRemoved:connect(RemovePlaneTool)
-----------------------------------------------------------------------------------
function CheckPlayer(Player) --This function checks the player
	if Customize.GroupSpecific.Value then --If the GroupSpecific value is true...
		if not Player:IsInGroup(Customize.GroupSpecific.GroupID.Value) then --If the player is not part of the group...
			return false
		end
	end
	return true
end

function CreateWarning(Player)
	local RbxGui = assert(LoadLibrary("RbxGui"))
	local Screen = Instance.new("ScreenGui")
	Screen.Name = "NotInGroupGui"
	local Gui = RbxGui.CreateStyledMessageDialog(
		"You are not in this plane's group!",
		Player.Name .. ", you are not a part of the group that this plane is in! Please exit the plane!",
		"Confirm",
		{
			{
				Text = "OK",
				Function = function()
					if Screen.Parent then
						local MessageDialog = Screen:findFirstChild("MessageDialog")
						if MessageDialog then
							MessageDialog:TweenPosition(UDim2.new(0.25, 0, 0, -165), "In", "Back", 0.7, true)
						end
						wait(0.7)
						Screen:Destroy()
					end
				end,
			},
		}
	)
	Gui.Parent = Screen
	Screen.Parent = Player.PlayerGui
	return Screen
end

function GivePlaneTool(Child) --This function puts the tool in the player by using the "SeatWeld"
	if Child.Name == "SeatWeld" then
		Player = game.Players:GetPlayerFromCharacter(Child.Part1.Parent) --This gets the Player
		if Player then
			local Check = CheckPlayer(Player)
			if Check then
				PlaneMain.Parent = Player.Character --This makes the plane a part of the Player's Character
				Plane = PlaneTool:clone()
				Plane.Parent = Player.Backpack
				Plane.Main.Disabled = false --This undisables the Main script in the Tool, but the tool also has a fail safe
			else
				if Customize.GroupSpecific.KillOnEnter.Value then
					wait(0.1)
					if Player.Character then
						Player.Character.Humanoid.Health = 0
					end
				else
					local Gui = CreateWarning(Player)
					delay(7, function()
						if Gui.Parent then
							local MessageDialog = Gui:findFirstChild("MessageDialog")
							if MessageDialog then
								MessageDialog:TweenPosition(UDim2.new(0.25, 0, 0, -165), "In", "Back", 0.7, true)
							end
							wait(0.7)
							Gui:Destroy()
						end
					end)
				end
			end
		end
	end
end

function RemovePlaneTool(Child) --This function removes the tool
	if Child.Name == "SeatWeld" then
		if Player and Player.PlayerGui:findFirstChild("NotInGroupGui") then
			Player.PlayerGui["NotInGroupGui"]:Destroy()
		end
		if Plane then
			Plane.Deselect0.Value = Plane.ToolSelect.Value --This makes the Deselect0 value on the plane tool true, which forces deselection
			wait(0.01) --This gives the tool enough time to activate the function
			Plane:remove() --This removes the plane tool
			if Player.Character.Humanoid.Health <= 0 then --If the Player dies...
				PlaneMain:BreakJoints() --These 3 lines break the plane and remove it after 5 seconds
				Crashed.Value = true
				delay(5, function()
					PlaneMain:Destroy()
				end)
			elseif Player.Character.Humanoid.Health > 0 then --If you just jump out of the seat without deselecting the tool...
				PlaneMain.Parent = Origin.Value --This puts the plane back into the Planekit folder
			end
		end
	end
end
Seat.ChildAdded:connect(GivePlaneTool) --This activates the "GivePlaneTool" function when you sit on the seat
Seat.ChildRemoved:connect(RemovePlaneTool) --This activates the "RemovePlaneTool" function when you get off the seat
