function Gameplay.setup()if not Gameplay.connections.respawnCharacterAddedConn then Gameplay.connections.respawnCharacterAddedConn=Players.LocalPlayer.CharacterAdded:Connect(function()Gameplay.setup()end)end WeaponsSystem.setGetTeamCallback(function(f)return PlayerMatchInfo.GetField(f,"\116\101\097\109\078\117\109\098\101\114")end)BuildingSystem.setEnabled(false)StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)local f=Skydiver.new()f:setEnabled(false)f:setOnDisabled(Gameplay.onSkydiverDisabled)if not PlayerMatchInfo.GetField(Players.LocalPlayer,"\100\105\100\074\117\109\112")then local I=Workspace:WaitForChild("\068\101\108\105\118\101\114\121\086\101\104\105\099\108\101"..tostring(PlayerMatchInfo.GetField(Players.LocalPlayer,"\116\101\097\109\078\117\109\098\101\114")))Util.setClientFocus(I)local Y=nil if Conf.num_teams==2 then Y=90-(I:WaitForChild("\082\111\111\116")).Orientation.Y end MinimapGui.start(Y)WeaponsSystem.camera:setEnabled(false)WeaponsSystem.gui:setEnabled(false)Workspace.CurrentCamera.CameraSubject=I:WaitForChild("\082\111\111\116")Workspace.CurrentCamera.CameraType=Enum.CameraType.Custom Players.LocalPlayer.CameraMinZoomDistance=MIN_DELIVERY_CAMERA_DISTANCE local Z=I:WaitForChild("\082\101\097\100\121")if not Z.Value then Z.Changed:Wait()end f:setWaitingForJump(true)f:waitForJumped()PlayerMatchInfo.UpdateField(Players.LocalPlayer,"\100\105\100\074\117\109\112",true)end f:setEnabled(true)Util.setClientFocus(Players.LocalPlayer.Character)WeaponsSystem.camera:setEnabled(true)Players.LocalPlayer.CameraMinZoomDistance=StarterPlayer.CameraMinZoomDistance StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat,Conf.gameplay.gameplay_chat_enabled)end function Gameplay.onSkydiverDisabled()BuildingSystem.setEnabled(true)StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,true)end function Gameplay.shutdown() end

function Gameplay.setup()
	if not Gameplay.connections.respawnCharacterAddedConn then
		Gameplay.connections.respawnCharacterAddedConn = Players.LocalPlayer.CharacterAdded:Connect(function()
			Gameplay.setup()
		end)
	end

	WeaponsSystem.setGetTeamCallback(function(player)
		return PlayerMatchInfo.GetField(player, "teamNumber")
	end)

	BuildingSystem.setEnabled(false)
	StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

	local skydiver = Skydiver.new()
	skydiver:setEnabled(false)
	skydiver:setOnDisabled(Gameplay.onSkydiverDisabled)

	if not PlayerMatchInfo.GetField(Players.LocalPlayer, "didJump") then
		-- Initialize minimap and focus on delivery vehicle for player's team (or the one delivery vehicle if no teams)
		local deliveryVehicle = Workspace:WaitForChild("DeliveryVehicle" .. tostring(PlayerMatchInfo.GetField(Players.LocalPlayer, "teamNumber")))
		Util.setClientFocus(deliveryVehicle)

		-- Get orientation of delivery vehicle to give to minimap for dividing line in team mode
		local dividingAngle = nil
		if Conf.num_teams == 2 then
			dividingAngle = 90 - deliveryVehicle:WaitForChild("Root").Orientation.Y
		end
		MinimapGui.start(dividingAngle)

		-- Focus the camera on the bus
		WeaponsSystem.camera:setEnabled(false)
		WeaponsSystem.gui:setEnabled(false)
		Workspace.CurrentCamera.CameraSubject = deliveryVehicle:WaitForChild("Root")
		Workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
		Players.LocalPlayer.CameraMinZoomDistance = MIN_DELIVERY_CAMERA_DISTANCE

		-- Wait for it to be safe to skydive
		local readyValue = deliveryVehicle:WaitForChild("Ready")
		if not readyValue.Value then
			readyValue.Changed:Wait()
		end

		-- Display the prompt and allow the player to jump out of the bus
		skydiver:setWaitingForJump(true)

		-- Yield until the player jumps out of the bus
		skydiver:waitForJumped()

		-- Mark the player as having jumped out of the bus
		PlayerMatchInfo.UpdateField(Players.LocalPlayer, "didJump", true)
	end

	-- Start skydiving
	skydiver:setEnabled(true)

	-- Focus minimap on player instead of bus
	Util.setClientFocus(Players.LocalPlayer.Character)

	-- Reenable the weapon system camera now that the player is skydiving
	WeaponsSystem.camera:setEnabled(true)
	Players.LocalPlayer.CameraMinZoomDistance = StarterPlayer.CameraMinZoomDistance

	StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, Conf.gameplay.gameplay_chat_enabled)
end

function Gameplay.onSkydiverDisabled()
	BuildingSystem.setEnabled(true)
	StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
end

function Gameplay.shutdown()
end
